UPDATE 最后,这与Azure文件共享无关 . Azure Disk和NFS或HostPath实际上是相同的情况
我已使用mountPath / data将Azure文件共享卷安装到mongoDb pod . 一切似乎都按预期工作 . 当我执行进入pod时,我可以在/ data / db中看到mongo数据 . 但在Azure文件共享上,我只能看到文件夹/ db和/ dbconfig,而不是文件 . 任何的想法 ?我已将权限0777授予该卷 .
这是我的yaml文件
StorageClass
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: azurefile
provisioner: kubernetes.io/azure-file
mountOptions:
- dir_mode=0777
- file_mode=0777
- uid=999
- gid=999
parameters:
storageAccount: ACCOUNT_NAME
skuName: Standard_LRS
PVC
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: azurefile
spec:
accessModes:
- ReadWriteMany
storageClassName: azurefile
resources:
requests:
storage: 20Gi
Mongo部署文件
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: mongo
labels:
app: mongo
namespace: development
spec:
replicas: 1
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
spec:
containers:
- name: mongo
image: "mongo"
imagePullPolicy: IfNotPresent
ports:
- containerPort: 27017
protocol: TCP
volumeMounts:
- mountPath: /data
name: mongovolume
subPath: mongo
imagePullSecrets:
- name: secret-acr
volumes:
- name: mongovolume
persistentVolumeClaim:
claimName: azurefile
Kubernetes版本
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:17:39Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.6", GitCommit:"a21fdbd78dde8f5447f5f6c331f7eb6f80bd684e", GitTreeState:"clean", BuildDate:"2018-07-26T10:04:08Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
2 回答
通过更改docker.io/bitnami/mongodb:4.0.2-debian-9的mongo图像解决了这个问题 . 使用此图像,mongo数据将写入文件共享,并且数据现在是持久的
此设置不适用于Azure文件或Azure磁盘 . 我正在处理其中一个项目,我遇到类似的问题,并采取Azure支持,但他们没有相同的具体解决方案 .
Azure支持提供的根本原因:不保持持久性的数据/文件是拥有 mongodb 的数据/文件 .