使用Oracle对象存储作为Oracle Kubernetes Engine中的持久卷。

huangapple go评论58阅读模式
英文:

Using Oracle Object Storage as a persistent Volume in Oracle Kubernetes Engine

问题

我正在尝试将Oracle Object Storage用作Oracle Kubernetes Engine中的持久卷。

我已经创建了一个Kubernetes集群并创建了一个名为test-bucket的公共存储桶。

我的YAML文件如下:

storage-class.yaml

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: object-storage
provisioner: oci.oraclecloud.com/object-storage
parameters:
  compartment-id: 
  bucket-name: test-bucket
  access-key: 
  secret-key: 

pvc.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: object-storage-pvc
spec:
  storageClassName: object-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi

pod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: object-storage-pod
spec:
  containers:
  - name: object-storage-container
    image: busybox
    command: ["sleep", "infinity"]
    volumeMounts:
    - name: object-storage
      mountPath: /home/user/data
  volumes:
  - name: object-storage
    persistentVolumeClaim:
      claimName: object-storage-pvc

我已经应用了所有文件,但在创建PVC时收到以下错误。

Normal  ExternalProvisioning  3m2s (x26 over 8m53s)  persistentvolume-controller  waiting for a volume to be created, either by external provisioner "oci.oraclecloud.com/object-storage" or manually created by system administrator

我也尝试过自己创建卷,但也没有成功。

我尝试了许多不同的方法,但不确定是否漏掉了什么。

感激任何帮助。

谢谢

英文:

I am trying to use Oracle Object Storage as a persistent Volume in Oracle Kubernetes Engine.

I have created a Kubernetes cluster and created a public bucket named test-bucket.

My yaml files are:

storage-class.yaml

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: object-storage
provisioner: oci.oraclecloud.com/object-storage
parameters:
  compartment-id: 
  bucket-name: test-bucket
  access-key: 
  secret-key: 

pvc.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: object-storage-pvc
spec:
  storageClassName: object-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi

pod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: object-storage-pod
spec:
  containers:
  - name: object-storage-container
    image: busybox
    command: ["sleep", "infinity"]
    volumeMounts:
    - name: object-storage
      mountPath: /home/user/data
  volumes:
  - name: object-storage
    persistentVolumeClaim:
      claimName: object-storage-pvc

I have applied all of the files but I am receiving this error when I create the PVC.

Normal  ExternalProvisioning  3m2s (x26 over 8m53s)  persistentvolume-controller  waiting for a volume to be created, either by external provisioner "oci.oraclecloud.com/object-storage" or manually created by system administrator

I also tried to create the volume by myself but that also didn't work.

I have tried many different things but I am not sure If I am missing anything here.

Any help would be appreciated.

Thanks

答案1

得分: 1

我不认为这会起作用,因为目前OCI不支持将对象存储用作持久卷(PVC)。

以下是一个可行的替代方案,但目前需要手动操作:

在每个节点上安装s3fs。这将允许您将S3存储桶(包括OCI的S3)挂载为一个挂载文件夹。然后,您可以使用主机路径将卷挂载到容器中。如果重新启动节点,您需要重新挂载存储桶,或者设置一个服务在重新启动时启动。如果您有多个节点,或者经常删除/添加节点,这可能会有些麻烦。

英文:

I don't think that would work, as using object storage as a PVC is currently not supported by OCI.

Here's an alternative that would work, but currently involves manual steps:

Install s3fs on each of your nodes. This will allow you to mount s3 bucket (including OCI's S3) as a mount folder. Then you can mount the volume into your container, using host path. If you restart your nodes, you will need to remmount the bucket, or setup a service to startup on reboot. If you have multiple nodes, or constantly delete/add nodes, it could be a pain.

huangapple
  • 本文由 发表于 2023年7月4日 20:10:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76612483.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定