---
apiVersion: v1
kind: Service
metadata:
  name: mongo-express
  labels:
    app: mongo-express
spec:
  clusterIP: None
  selector:
    app: mongo-express
  ports:
    - port: 8081
      name: mongo-express
      protocol: TCP
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mongo-express
spec:
  selector:
    matchLabels:
      app: mongo-express
  serviceName: mongo-express
  template:
    metadata:
      labels:
        app: mongo-express
    spec:
      restartPolicy: Always
      terminationGracePeriodSeconds: 0
      containers:
        - name: mongo-express
          image: mongo-express:latest
          env:
            - name: ME_CONFIG_MONGODB_ADMINUSERNAME
              value: root
            - name: ME_CONFIG_MONGODB_ADMINPASSWORD
              value: example
            - name: ME_CONFIG_MONGODB_URL
              value: mongodb://mongo-0.mongo/?replicaSet=rs0
          readinessProbe:
            tcpSocket:
              port: 8081
            periodSeconds: 1
            failureThreshold: 300
          ports:
            - containerPort: 8081
              name: mongo-express
              protocol: TCP
