创建 mongodb 副本集时出错 - 显示无法识别的选项“--smallfiles”

Error when creating a mongodb replicaset - shows unrecognized option '--smallfiles'

我正在创建下面的 mongodb statefulset,它创建了 3 个副本,但是当我 运行 代码时,我得到以下错误并且所有 pods 都处于 CrashLoopBackOff 状态。

这是我在尝试 kubectl create -f

时遇到的错误
Error parsing command line: unrecognised option '--smallfiles' 
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
 name: mongo
 namespace: microservice1
spec:
 serviceName: "mongo"
 replicas: 3
 template:
   metadata:
     labels:
       role: mongo
       environment: test
   spec:
     terminationGracePeriodSeconds: 10
     containers:
       - name: mongo
         image: mongo
         command:
           - mongod
           - "--replSet"
           - rs0
           - "--smallfiles"
           - "--noprealloc"
         ports:
           - containerPort: 27017
         volumeMounts:
           - name: mongo-persistent-storage
             mountPath: /data/db
       - name: mongo-sidecar
         image: cvallance/mongo-k8s-sidecar
         env:
           - name: MONGO_SIDECAR_POD_LABELS
             value: "role=mongo,environment=test"
     volumes:
      - name: mongo-persistent-storage
        flexVolume:
          driver: rook.io/rook
          fsType: ceph
          options:
            fsName: myfs # name of the filesystem specified in the filesystem CRD.
            clusterNamespace: rook # namespace where the Rook cluster is deployed
            clusterName: rook

--smallfiles 不支持最新的 mongo (4.2) 你可以在 doc 中检查它,你没有指定图像标签所以最新的 latest 被引入这种情况 mongo 4.2。

如果你设置 image: mongo:4.0 你的配置应该是正确的。

尝试删除小文件,否则请尝试我提供的下面的块。

apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app: mongodb-replicaset
    name: logs-mongodb-replicaset
spec:
  podManagementPolicy: OrderedReady
  replicas: 3
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: mongodb-replicaset
  serviceName: logs-mongodb-replicaset
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: mongodb-replicaset
    spec:
      containers:
      - args:
        - --config=/data/configdb/mongod.conf
        - --dbpath=/data/db
        - --replSet=rs0
        - --port=27017
        - --bind_ip=0.0.0.0
        command:
        - mongod
        image: mongo:3.6
        imagePullPolicy: IfNotPresent
        livenessProbe:
          exec:
            command:
            - mongo
            - --eval
            - db.adminCommand('ping')
          failureThreshold: 3
          initialDelaySeconds: 30
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 5
        name: mongodb-replicaset
        ports:
        - containerPort: 27017
          name: peer
          protocol: TCP
        readinessProbe:
          exec:
            command:
            - mongo
            - --eval
            - db.adminCommand('ping')
          failureThreshold: 3
          initialDelaySeconds: 5
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /data/db
          name: datadir
        - mountPath: /data/configdb
          name: configdir
        - mountPath: /work-dir
          name: workdir