重新启动后牧场主持久数据丢失

时间:2019-05-20 09:00:17

标签: docker kubernetes rancher

我已经在牧场主集群中安装了nfs-provisioner。我为MongoDB制作了持久卷。当我重新启动服务器或升级mongodb容器时,所有数据都丢失了。该如何解决?

我的mongodb配置

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mongo-db
spec:
  selector:
    matchLabels:
      app: mongo-db
  serviceName: mongo-db
  replicas: 3
  template:
    metadata:
      labels:
        app: mongo-db
    spec:
      containers:
      - name: mongodb
        image: mongo
        ports:
        - containerPort: 27017
        volumeMounts:
        - name: data #reference the volumeClaimTemplate below
          mountPath: /data/db
  #this is a key difference with statefulsets
  #A unique volume will be attached to each pod
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes: ["ReadWriteOnce"]
      #If no storageClassName is provided the default storage class will be used
      #storageClassName: "standard"  
      resources:
        requests:
          storage: 2Gi

1 个答案:

答案 0 :(得分:0)

我修复了此安装的longhorn。谢谢大家!

相关问题