apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongodb-deployment 
  namespace: {{ .Values.namespace }}
  labels:
    app: mongodb
spec:
  replicas: 1 # Cannot be scaled. To scale, you must set up Stateful Set
  selector:
    matchLabels:
      app: mongodb 
  template:
    metadata: 
      labels:
        app: mongodb 
    spec:
      containers:
      - name: mongodb 
        image: mongo
        ports: 
        - containerPort: 27017
        env:
        - name: MONGO_INITDB_ROOT_USERNAME
          value: root
        - name: MONGO_INITDB_ROOT_PASSWORD
          value: root
---
apiVersion: v1
kind: Service 
metadata:
  name: mongodb-service
  namespace: {{ .Values.namespace }} 
spec:
  selector:
    app: mongodb 
  ports:
    - protocol: TCP
      port: 27017
      targetPort: 27017 # container port 
