apiVersion: apps/v1
kind: Deployment
metadata:
  name: team-planner-backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: team-planner-backend
  template:
    metadata:
      labels:
        app: team-planner-backend
    spec:
      imagePullSecrets:
      - name: harbor-creds
      containers:
      - name: team-planner-backend
        image: __BACKEND_IMAGE__
        ports:
        - containerPort: 4001
        env:
        - name: NODE_ENV
          value: "production"
        - name: PORT
          value: "4001"
        - name: DB_HOST
          value: "postgres-service"
        - name: DB_PORT
          value: "5432"
        - name: DB_DATABASE
          valueFrom:
            secretKeyRef:
              name: team-planner-secrets
              key: db-name
        - name: DB_USERNAME
          valueFrom:
            secretKeyRef:
              name: team-planner-secrets
              key: db-user
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: team-planner-secrets
              key: db-password
        - name: KEYCLOAK_REALM_URL
          value: "https://auth.vigdorov.ru/realms/team-planner"
        resources:
          requests:
            memory: "256Mi"
            cpu: "250m"
          limits:
            memory: "512Mi"
            cpu: "500m"
        livenessProbe:
          httpGet:
            path: /api/health
            port: 4001
          initialDelaySeconds: 30
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /api/health
            port: 4001
          initialDelaySeconds: 10
          periodSeconds: 5
