juicefs csi 集成试用


主要是一个试用,对于k8s 使用了minikube

minikube 安装

这个直接可以参考官方文档 (注意可能需要合理上网)

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64
sudo install minikube-darwin-amd64 /usr/local/bin/minikube
minikube start

部署juicefs csi driver

官方提供了部署文档参考

  • 部署csi driver
kubectl apply -f https://raw.githubusercontent.com/juicedata/juicefs-csi-driver/master/deploy/k8s.yaml
  • 动态配置
    secret
 
kubectl -n default create secret generic juicefs-secret \
    --from-literal=name=mydemoapp \
    --from-literal=metaurl=redis://@:6379 \
    --from-literal=storage=minio \
    --from-literal=bucket=http:///juicefsapp \
    --from-literal=access-key=<key>\
    --from-literal=secret-key=<secret>
  • 创建存储类以及pv&pvc&pod
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: juicefs-sc
  namespace: default
provisioner: csi.juicefs.com
parameters:
  csi.storage.k8s.io/provisioner-secret-name: juicefs-secret
  csi.storage.k8s.io/provisioner-secret-namespace: default
  csi.storage.k8s.io/node-publish-secret-name: juicefs-secret
  csi.storage.k8s.io/node-publish-secret-namespace: default
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: juicefs-pvc
  namespace: default
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 10Pi
  storageClassName: juicefs-sc
---
apiVersion: v1
kind: Pod
metadata:
  name: juicefs-app
  namespace: default
spec:
  containers:
  - args:
    - -c
    - while true; do echo $(date -u) >> /data/out.txt; sleep 5; done
    command:
    - /bin/sh
    image: centos
    name: app
    volumeMounts:
    - mountPath: /data
      name: juicefs-pv
  volumes:
  - name: juicefs-pv
    persistentVolumeClaim:
      claimName: juicefs-pvc
  • 效果

minikube dashboard

说明

官方提供了一些最佳实践很值得学习下,同时源码也是值得学习的

参考资料

https://juicefs.com/blog/cn/posts/csi-driver-best-practices/
https://minikube.sigs.k8s.io/docs/start/
https://juicefs.com/docs/zh/csi/introduction