Cập nhật lần cuối: 2025/01/20 11:29:56
Hướng dẫn này sẽ giúp khách hàng có thể sử dụng CMC Simple Storage Service làm nơi lưu trữ dữ liệu cho các pod CMC Kubernetes Engine.
Khách hàng có thể thực hiện các bước sau:
Bước 1 : Lấy thông tin truy cập Object Storage
Bước 2 : Cài đặt Container Storage Interface (CSI) cho cụm K8s
Cách 1 : Triển khai với Helm
helm repo add yandex-s3 https://yandex-cloud.github.io/k8s-csi-s3/charts |
wget https://raw.githubusercontent.com/yandex-cloud/k8s-csi-s3/v0.38.3/deploy/helm/csi-s3/values.yaml |
vi values.yaml |
storageClass: ... # GeeseFS mount options mountOptions: "--memory-limit 1000 --dir-mode 0777 --file-mode 0666" ... secret: # Specifies whether the secret should be created create: true # Name of the secret name: csi-s3-secret # S3 Access Key accessKey: "<S3_Key>" # S3 Secret Key secretKey: "<S3_Secret_Key>" # Endpoint endpoint: https://<Endpoint> |
helm install -f values.yaml --namespace kube-system csi-s3 yandex-s3/csi-s3 |
Cách 2 : Triển khai bằng Kubectl
vi secret.yaml |
apiVersion: v1 kind: Secret metadata: name: csi-s3-secret # Namespace depends on the configuration in the storageclass.yaml namespace: kube-system stringData: accessKeyID: <S3_Key> secretAccessKey: <S3_Secret_Key> # For AWS set it to "https://s3.<region>.amazonaws.com", for example https://s3.eu-central-1.amazonaws.com endpoint: https://<Endpoint> |
kubectl apply -f secret.yaml |
kubectl create -f https://raw.githubusercontent.com/yandex-cloud/k8s-csi-s3/v0.38.3/deploy/kubernetes/provisioner.yaml kubectl create -f https://raw.githubusercontent.com/yandex-cloud/k8s-csi-s3/v0.38.3/deploy/kubernetes/driver.yaml kubectl create -f https://raw.githubusercontent.com/yandex-cloud/k8s-csi-s3/v0.38.3/deploy/kubernetes/csi-s3.yaml |
--- kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: csi-s3 provisioner: ru.yandex.s3.csi parameters: mounter: geesefs # you can set mount options here, for example limit memory cache size (recommended) options: "--memory-limit 1000 --dir-mode 0777 --file-mode 0666" # to use an existing bucket, specify it here: #bucket: some-existing-bucket csi.storage.k8s.io/provisioner-secret-name: csi-s3-secret csi.storage.k8s.io/provisioner-secret-namespace: kube-system csi.storage.k8s.io/controller-publish-secret-name: csi-s3-secret csi.storage.k8s.io/controller-publish-secret-namespace: kube-system csi.storage.k8s.io/node-stage-secret-name: csi-s3-secret csi.storage.k8s.io/node-stage-secret-namespace: kube-system csi.storage.k8s.io/node-publish-secret-name: csi-s3-secret csi.storage.k8s.io/node-publish-secret-namespace: kube-system |
Bước 3 : Kiểm tra trong Cluster :
vi example.yaml |
apiVersion: v1 kind: Pod metadata: name: test-nginx spec: containers: - name: test image: nginx volumeMounts: - name: config mountPath: /usr/share/nginx/html volumes: - name: config persistentVolumeClaim: claimName: pvc-nginx --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-nginx spec: accessModes: - ReadWriteMany storageClassName: CSI-S3 resources: requests: storage: 26Gi |
kubectl apply -f example.yaml |
Điều khoản & Chính sách