使用Kubernetes部署应用程序中的Windows SMB共享

我们正在将遗留的
Java和.net应用程序从本地VM迁移到本地Kubernetes集群.

其中许多应用程序使用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中的节点,这可以吗?

最佳答案 我在r / kubernetes上问了同样的问题,用户对此进行了评论.我们现在正在尝试这个,似乎没问题.

https://www.reddit.com/r/kubernetes/comments/7wcwmt/accessing_windows_smbcifs_shares_from_pods/duzx0rs/

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.

点赞