apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mongo
  namespace: default
spec:
  selector:
    matchLabels:
      app: mongo
  serviceName: mongo-svc
  # replicas: 1 by default is 1
  template:
    metadata:
      labels:
        app: mongo
    spec:
      containers:
      - env:
        - name: MONGO_INITDB_ROOT_USERNAME
          value: strapi
        - name: MONGO_INITDB_ROOT_PASSWORD
          value: strapi
        image: mongo
        imagePullPolicy: IfNotPresent
        name: mongo
        ports:
        - containerPort: 27017
          name: mongo
          protocol: TCP
        volumeMounts:
        - mountPath: /data/db
          name: www
      # dnsPolicy: ClusterFirst
  volumeClaimTemplates:
  - apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: www
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 500Mi
      volumeMode: Filesystem
