apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongodb
  labels:
    dpl: mongodb
  namespace: mongo
spec:
  replicas: 1
  selector:
    matchLabels:
      pod: mongodb
  template:
    metadata:
      labels:
        pod: mongodb
    spec:
      containers:
        - name: mongodb
          image: mongo:latest
          ports:
            - containerPort: 27017
          env:
            - name: MONGO_INITDB_ROOT_USERNAME
              valueFrom:
                secretKeyRef:
                  name: mongodb-secret
                  key: root_user
            - name: MONGO_INITDB_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mongodb-secret
                  key: root_pass
