---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mod1-dsa-mongodb
  labels:
    app.kubernetes.io/name: mod1-dsa-mongodb
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: mod1-dsa-mongodb
  serviceName: mod1-dsa-mongodb
  replicas: 1
  template:
    metadata:
      labels:
        app.kubernetes.io/name: mod1-dsa-mongodb
        blinktShow: 'true'
        blinktColor: "009600"
    spec:
      containers:
        - name: mod1-dsa-mongodb
          image: library/mongo:4-bionic
          ports:
            - containerPort: 27017
          envFrom:
            - configMapRef:
                name: mod1-dsa-mongodb
          env:
            - name: MONGO_INITDB_ROOT_USERNAME
              valueFrom:
                secretKeyRef:
                  name: mod1-dsa-mongodb-secret
                  key: database-user
            - name: MONGO_INITDB_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mod1-dsa-mongodb-secret
                  key: database-password
          volumeMounts:
            - name: mongo-storage
              mountPath: /data/db
      restartPolicy: Always
  volumeClaimTemplates:
    - metadata:
        name: mongo-storage
      spec:
        storageClassName: "managed-nfs-storage"
        accessModes: [ "ReadWriteOnce" ]
        resources:
          requests:
            storage: 1Gi
