apiVersion: v1
kind: ConfigMap
metadata:
  name: backend-config
  namespace: python-navigator-demo
data:
  DB_HOST: postgres
  DB_PORT: "5432"
  DB_NAME: python-navigator-demo
  DB_USER: python-navigator-demo
  DEX_ISSUER: https://dex.127.0.0.1.sslip.io/
---
apiVersion: v1
kind: Secret
metadata:
  name: backend-secret
  namespace: python-navigator-demo
type: Opaque
stringData:
  DB_PASSWORD: python-navigator-demo
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend
  namespace: python-navigator-demo
spec:
  selector:
    matchLabels:
      app: backend
  template:
    metadata:
      labels:
        app: backend
    spec:
      containers:
      - name: backend
        image: python-navigator-demo-backend:latest
        imagePullPolicy: Never  # Для локальной разработки
        ports:
        - containerPort: 8000
        envFrom:
        - configMapRef:
            name: backend-config
        - secretRef:
            name: backend-secret
        livenessProbe:
          httpGet:
            path: /api/health
            port: 8000
          initialDelaySeconds: 10
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /api/health
            port: 8000
          initialDelaySeconds: 5
          periodSeconds: 5

---
apiVersion: v1
kind: Service
metadata:
  name: backend
  namespace: python-navigator-demo
spec:
  selector:
    app: backend
  ports:
  - port: 8000
    targetPort: 8000
  type: ClusterIP

