---

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mongo
spec:
  selector:
    matchLabels:
      app: mongo
  serviceName: mongo
  replicas: 1
  template:
    metadata:
      labels:
        app: mongo
    spec:
      terminationGracePeriodSeconds: 10
      containers:
        - name: mongo
          image: mongo
          command:
            - mongod
            - "-f"
            - "/etc/mongod.conf"
          ports:
            - containerPort: 27017
          volumeMounts:
            - name: mongo-storage
              mountPath: /var/lib/mongodb
            - name: mongodb-config
              mountPath: /etc/mongod.conf
              subPath: mongod.conf
      volumes:
        - name: mongodb-config
          configMap:
            name: mongodb
  volumeClaimTemplates:
    - metadata:
        name: mongo-storage
      spec:
        accessModes: [ "ReadWriteOnce" ]
        resources:
          requests:
            storage: 2Gi