apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend-deployment
  annotations:
    kompose.service.type: LoadBalancer
  labels:
    backend.service: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      backend.service: backend
  template:
    metadata:
      annotations:
        kompose.service.type: LoadBalancer
      labels:
        backend.service: backend
    spec:
      containers:
      - name: backend-spring-app-image
        image: ankitrajput/springboot_app_with_db:6.0.0
        ports:
          - containerPort: 8080
        env:    
          - name: POSTGRES_URL
            value: "postgresql-db-service"        
          - name: POSTGRES_PORT
            value: "5432"                        
          - name: POSTGRES_USER
            value: "ankit"        # RDS DB Username is 'ankit'     
          - name: POSTGRES_PASSWORD
            valueFrom:
              secretKeyRef:
                name: kubernetes-password
                key: db-password
        livenessProbe:
          httpGet:
            path: /actuator/health/liveness
            port: 8080
          initialDelaySeconds: 60
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /actuator/health/readiness
            port: 8080
          initialDelaySeconds: 60
          periodSeconds: 10  
      restartPolicy: Always
