如何在Kubernetes里使用Minio存储

286 字
1 分钟
如何在Kubernetes里使用Minio存储

1 部署驱动#

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

下载此目录所有文件

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

Terminal window
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

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

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#

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

查看

Terminal window
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#

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

查看

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

文章分享

如果这篇文章对你有帮助,欢迎分享给更多人!

如何在Kubernetes里使用Minio存储
https://ccops.cc/posts/a03ee434/
作者
蹦蹦站长
发布于
2022-04-01
许可协议
CC BY-NC-SA 4.0

评论区

Profile Image of the Author
蹦蹦站长
一个养兔子的运维
公告
感谢你的来访!希望在这里能找到对你有用的内容!
音乐
封面

音乐

暂未播放

0:00 0:00
暂无歌词
分类
标签
站点统计
文章
81
分类
6
标签
45
总字数
88,456
运行时长
0
最后活动
0 天前
站点信息
构建平台
Local
博客版本
Firefly v6.12.1
文章许可
CC BY-NC-SA 4.0

文章目录