1 部署驱动

minio 部署参考: 使用minion当blog图床

下载此目录所有文件

可以参考官网的,需要自己改镜像

1
2
3
4
5
6
7
8
kubectl apply -f . -n minio
kubectl get pod -n minio
NAME READY STATUS RESTARTS AGE
csi-attacher-s3-0 1/1 Running 0 16h
csi-provisioner-s3-0 2/2 Running 0 16h
csi-s3-2dfnn 2/2 Running 0 16h
csi-s3-nn5pp 2/2 Running 0 16h
csi-s3-q9pln 2/2 Running 0 16h

2 Storageclass

创建 Secret

1
2
3
4
5
6
7
8
9
10
11
cat secret.yaml
apiVersion: v1
kind: Secret
metadata:
namespace: minio
name: csi-s3-secret
stringData:
accessKeyID: "admin" # minio用户名,明文就可以
secretAccessKey: "xxxxxxxxx" # minio密码,明文就可以
endpoint: http://10.1.1.1:9000 # minio api地址
kubectl apply -f secret.yaml -n minio

创建 Storageclass

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
cat sc.yaml
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: csi-s3
provisioner: ch.ctrox.csi.s3-driver
parameters:
mounter: s3fs
csi.storage.k8s.io/provisioner-secret-name: csi-s3-secret
csi.storage.k8s.io/provisioner-secret-namespace: minio
csi.storage.k8s.io/controller-publish-secret-name: csi-s3-secret
csi.storage.k8s.io/controller-publish-secret-namespace: minio
csi.storage.k8s.io/node-stage-secret-name: csi-s3-secret
csi.storage.k8s.io/node-stage-secret-namespace: minio
csi.storage.k8s.io/node-publish-secret-name: csi-s3-secret
csi.storage.k8s.io/node-publish-secret-namespace: minio
reclaimPolicy: Delete
volumeBindingMode: Immediate
kubectl apply -f sc.yaml -n minio

3 验证

3.1 创建 pvc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
cat pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: csi-s3-pvc
namespace: minio
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: csi-s3
kubectl apply -f pvc.yaml -n minio

查看

1
2
3
kubectl get pvc -n minio
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
csi-s3-pvc Bound pvc-df3ed2a7-6086-450d-8c17-ff40ab9a1fb4 5Gi RWO csi-s3 16h

3.2 创建 pod

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
cat pod.yaml
kind: Pod
apiVersion: v1
metadata:
name: minio-pod
namespace: minio
spec:
containers:
- name: minio-pod
image: nginx
volumeMounts:
- name: pvc
mountPath: "/mnt"
volumes:
- name: pvc
persistentVolumeClaim:
claimName: csi-s3-pvc
readOnly: false
kubectl apply -f pod.yaml -n minio

查看

1
2
3
kubectl get pod -n minio
NAME READY STATUS RESTARTS AGE
minio-pod 1/1 Running 0 16h