其中许多应用程序使用Windows文件共享来从其他现有系统传输文件.部署到Kubernetes的优先级低于重新设计所有解决方案以避免使用samba共享,因此如果我们想要迁移,我们必须找到一种方法来保持很多东西.
我们使用Kubeadm和Canal在3台中心7台机器上建立了一个3节点集群.
除了azure卷之外,我找不到任何主动维护的插件或库来安装SMB.
我想到的是在所有节点上使用相同的挂载点在每个centos节点上挂载SMB共享,即:“/ data / share1”,然后我创建了一个本地PersistentVolume
kind: PersistentVolume apiVersion: v1 Metadata: name: samba-share-volume labels: type: local spec: storageClassName: manual capacity: storage: 2Gi accessModes: - ReadWriteMany hostPath: path: "/data/share1"
和索赔,
kind: PersistentVolumeClaim apiVersion: v1 Metadata: name: samba-share-claim spec: storageClassName: manual accessModes: - ReadWriteMany resources: requests: storage: 1Gi
并将索赔分配给申请.
apiVersion: extensions/v1beta1 kind: Deployment Metadata: name: samba-share-deployment spec: replicas: 2 template: Metadata: labels: app: samba-share-deployment tier: backend spec: containers: - name: samba-share-deployment image: Nginx ports: - containerPort: 80 volumeMounts: - mountPath: "/usr/share/Nginx/html" name: samba-share-volume volumes: - name: samba-share-volume persistentVolumeClaim: claimName: samba-share-claim
它适用于每个副本,但有关于在生产中使用本地卷的巨大警告.我不知道有任何其他方法可以做到这一点或使用此配置的实际注意事项.
我可以用另一种方式吗?如果我监视挂载点并在挂载失败时禁用kubernetes中的节点,这可以吗?
解决方法
We had to deal with a similar situation and I ended up developing a
custom Flexvolume driver to mount CIFS shares into pods from examples
I found online.I have written a repo with the solution that works for my use case.
07001
You still need to intall cifs-utils and jq on each Kubernetes host as
a pre-requisite. But it does allow you to create PersistentVoluems
that mount CIFS volumes and use them in your pods.I hope it helps.