apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mongodb-statefulset
  labels:
    app: mongodb
spec:
  serviceName: "mongodb"
  replicas: 1
  selector:
    matchLabels:
      app: mongodb
  template:
    metadata:
      labels:
        app: mongodb
    spec:
      containers:
      - name: mongodb
        image: mongo:latest
        envFrom:
        - configMapRef:
            name: mongodb-configuration
        ports:
        - containerPort: 27017
          name: mongodb
        volumeMounts:
        - name: mongodb-data
          mountPath: /var/snap/microk8s/common/default-storage/mongodb/data
      volumes:
      - name: mongodb-data
        persistentVolumeClaim:
          claimName: mongodb-pv-claim