apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend-deployment
  namespace: todo-namespace
spec:
  replicas: 2
  selector:
    matchLabels:
      app: backend
  template:
    metadata:
      labels:
        app: backend
    spec:
      containers:
        - name: backend-container
          image: backend-image:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 9876
          env:
            - name: MONGO_USER
              value: tododbuser
            - name: MONGO_PASSWORD
              value: tododbadminpassword
            - name: MONGO_HOST
              value: mongodb-service
            - name: MONGO_PORT
              value: "27017"
            - name: MONGO_DB
              value: todo

---
apiVersion: v1
kind: Service
metadata:
  name: backend-service
spec:
  selector:
    app: backend
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9876
  type: ClusterIP
