apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mongo
spec:
  selector:
    matchLabels:
      app: mongo
  serviceName: mongo
  replicas: 3
  template:
    metadata:
      labels:
        app: mongo
    spec:
      containers:
      - name: mongodb
        image: mongo:3.4.1
        command: ["mongod", "--replSet", "rs0"]
        ports:
        - containerPort: 27017
          name: web
        livenessProbe:
          exec:
            command: ['/usr/bin/mongo', '--eval', 'db.serverStatus()']
          initialDelaySeconds: 10
          timeoutSeconds: 10
        volumeMounts:
        - name: database
          mountPath: /data/db
      # initializes the mongo replicas then sleeps
      # - name: init-mongo
      #   image: mongo:3.4.1
      #   command: ['bash', '/config/init.sh']
      #   volumeMounts:
      #   - name: config
      #     mountPath: /config
      # volumes:
      # - name: config
      #   configMap:
      #     name: mongo-init
  volumeClaimTemplates:
  - metadata:
      name: database
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: standard
      resources:
        requests:
          storage: 5Gi
