apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mongo
  namespace: open5gs
spec:
  serviceName: "mongodb"
  replicas: 1
  selector:
    matchLabels:
      role: mongo
  template:
    metadata:
      labels:
        role: mongo
        environment: test
    spec:
      serviceAccountName: mongo
      automountServiceAccountToken: true
      terminationGracePeriodSeconds: 10
      containers:
        - name: mongo
          image: mongo
          command:
            - mongod
          args:
            - "--replSet=rs0"
            - "--bind_ip=0.0.0.0"
          ports:
            - containerPort: 27017
          volumeMounts:
            - name: mongo-persistent-storage
              mountPath: /data/db
        - name: mongo-sidecar
          image: morphy/k8s-mongo-sidecar
          env:
            - name: KUBERNETES_POD_LABELS
              value: "role=mongo,environment=test"
            - name: KUBERNETES_SERVICE_NAME
              value: "mongodb"
      volumes:
      - name: mongo-persistent-storage
        emptyDir: {}
