gpt4 book ai didi

kubernetes - 从Kubernetes部署应用程序使用Windows SMB共享

转载 作者:行者123 更新时间:2023-12-03 16:40:40 24 4
gpt4 key购买 nike

我们正在将旧版Java和.net应用程序从本地VM迁移到本地Kubernetes集群。

这些应用程序中的许多应用程序都使用Windows文件共享在其他现有系统之间传输文件。与重新设计所有解决方案以避免使用samba共享相比,部署到Kubernetes的优先级要低,因此,如果要迁移,我们将必须找到一种方法来保持许多现状。

我们使用Kubeadm和Canal在3 centos 7机器上设置了一个3节点群集。

除了天蓝色卷,我找不到任何积极维护的插件或库来挂载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"

和 claim ,
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: samba-share-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi

并将 claim 要求分配给了该申请。
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.

https://github.com/juliohm1978/kubernetes-cifs-volumedriver

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.

关于kubernetes - 从Kubernetes部署应用程序使用Windows SMB共享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48747538/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com