apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongodb-deployment
  labels:
    app: mongodb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mongodb
  template:
    metadata:
      labels:
        app: mongodb
    spec:
      containers:
      - name: mongodb
        image: mongo:5.0.2
        ports:
          - containerPort: 27017
        volumeMounts:
        - name: db
          mountPath: /data/db
        - name: mongo-init
          mountPath: /docker-entrypoint-initdb.d
        env:
          - name: MONGO_INITDB_DATABASE
            value: "integration-service"
          - name: MONGO_INITDB_ROOT_USERNAME
            valueFrom:
              secretKeyRef:
                name: mongodb-secret
                key: mongo-root-username
          - name: MONGO_INITDB_ROOT_PASSWORD
            valueFrom:
              secretKeyRef:
                name: mongodb-secret
                key: mongo-root-password 
      volumes:
      - name: db
        emptyDir: {}
      - name: mongo-init
        configMap:
          name: init-mongo-cfg
          items:
          - key: mongo-init.js
            path: mongo-init.js
      
                  
