Mount S3 storage vào K8S cluster

Pre-condition

  • Đã tạo S3 pool.

  • Đã tạo ACL với quyền read & write cho tất cả bucket.

  • Đã tạo K8S.

Các bước thực hiện:

Bước 1. Cài đặt Helm

Link cài đặt: https://helm.sh/docs/intro/install/

Bước 2. Deploy CSI-S3 trên K8S

helm repo add yandex-s3 https://yandex-cloud.github.io/k8s-csi-s3/charts
helm repo update
helm show values yandex-s3/csi-s3 > values.yaml

Chỉnh sửa các thông số accesskey, secretkey, endpoint trong file values.yaml

---
images:
  # Source: quay.io/k8scsi/csi-node-driver-registrar:v1.2.0
  registrar: cr.yandex/crp9ftr22d26age3hulg/yandex-cloud/csi-s3/csi-node-driver-registrar:v1.2.0
  # Source: quay.io/k8scsi/csi-provisioner:v2.1.0
  provisioner: cr.yandex/crp9ftr22d26age3hulg/yandex-cloud/csi-s3/csi-provisioner:v2.1.0
  # Main image
  csi: cr.yandex/crp9ftr22d26age3hulg/yandex-cloud/csi-s3/csi-s3-driver:0.41.1
 
storageClass:
  # Specifies whether the storage class should be created
  create: true
  # Name
  name: csi-s3
  # Use a single bucket for all dynamically provisioned persistent volumes
  singleBucket: ""
  # mounter to use - either geesefs, s3fs or rclone (default geesefs)
  mounter: geesefs
  # GeeseFS mount options
  mountOptions: "--memory-limit 1000 --dir-mode 0777 --file-mode 0666"
  # Volume reclaim policy
  reclaimPolicy: Delete
  # Annotations for the storage class
  # Example:
  # annotations:
  #   storageclass.kubernetes.io/is-default-class: "true"
  annotations: {}
 
secret:
  # Specifies whether the secret should be created
  create: true
  # Name of the secret
  name: csi-s3-secret
  # S3 Access Key
  accessKey: "*****************"
  # S3 Secret Key
  secretKey: "*****************"
  # Endpoint
  endpoint: https://s3.sunteco.app
  # Region
  region: ""
 
tolerations:
  all: false
  node: []
  controller: []
 
nodeSelector: {}
 
kubeletPath: /var/lib/kubelet

Deploy CSI-S3 trong K8S

helm --kubeconfig={name_file_kubeconfig} upgrade --install csi-s3 yandex-s3/csi-s3 --namespace storage --create-namespace --values values.yaml

Bước 3. Kiểm tra việc mount S3 storage trên K8S

Tạo file pvc.yaml với nội dung:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  namespace: storage
  name: sang-pvc-s3
spec:
  storageClassName: csi-s3
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi

Chạy câu lệnh tạo pvc:

kubectl --kubeconfig={name_file_kubeconfig} apply -f pvc.yaml

Result:

Image
Image