---
apiVersion: v1
kind: Service
metadata:
  name: mongo
  labels:
    app: mongo
spec:
  clusterIP: None
  selector:
    app: mongo
  ports:
    - port: 27017
      name: mongo
      protocol: TCP
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mongo
spec:
  selector:
    matchLabels:
      app: mongo
  serviceName: mongo
  replicas: 1
  template:
    metadata:
      labels:
        app: mongo
    spec:
      restartPolicy: Always
      terminationGracePeriodSeconds: 0
      containers:
        - name: mongo
          image: mongo:latest
          command:
            - mongod
            - "--replSet"
            - rs0
            - "--bind_ip_all"
          env:
            - name: MONGO_INITDB_ROOT_USERNAME
              value: root
            - name: MONGO_INITDB_ROOT_PASSWORD
              value: example
          livenessProbe:
            tcpSocket:
              port: 27017
            periodSeconds: 1
            failureThreshold: 300
          readinessProbe:
            tcpSocket:
              port: 27017
            periodSeconds: 1
            failureThreshold: 300
          ports:
            - containerPort: 27017
              name: mongo
              protocol: TCP
          volumeMounts:
            - name: wormhole-explorer-mongo-data-dir
              mountPath: /data/db
  volumeClaimTemplates:
    - metadata:
        name: wormhole-explorer-mongo-data-dir
      spec:
        accessModes: [ "ReadWriteOnce" ]
        resources:
          limits:
            cpu: 10m
            memory: 50Mi
          requests:
            storage: 10Gi
            cpu: 10m
            memory: 50Mi