apiVersion: apps/v1
kind: Deployment
metadata:
  name: knck-app
  labels:
    app: knck-app
spec:
  replicas: 2
  selector:
    matchLabels:
      app: knck-app
  template:
    metadata:
      labels:
        app: knck-app
    spec:
      containers:
      - name: knck-frontend
        image: knck-frontend:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 80
        resources:
          requests:
            cpu: "50m"
            memory: "64Mi"
          limits:
            cpu: "100m"
            memory: "128Mi"
        readinessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 5
          periodSeconds: 10
        livenessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 15
          periodSeconds: 20
      - name: knck-backend
        image: knck-backend:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 3001
        env:
        - name: PORT
          value: "3001"
        - name: NODE_ENV
          value: "production"
        - name: SMTP_HOST
          valueFrom:
            secretKeyRef:
              name: knck-secrets
              key: smtp-host
        - name: SMTP_PORT
          valueFrom:
            secretKeyRef:
              name: knck-secrets
              key: smtp-port
        - name: SMTP_USER
          valueFrom:
            secretKeyRef:
              name: knck-secrets
              key: smtp-user
        - name: SMTP_PASS
          valueFrom:
            secretKeyRef:
              name: knck-secrets
              key: smtp-pass
        - name: SMTP_FROM
          valueFrom:
            secretKeyRef:
              name: knck-secrets
              key: smtp-from
        - name: SMTP_TO
          valueFrom:
            secretKeyRef:
              name: knck-secrets
              key: smtp-to
        - name: CORS_ORIGIN
          value: "https://knck.pl"
        resources:
          requests:
            cpu: "100m"
            memory: "128Mi"
          limits:
            cpu: "200m"
            memory: "256Mi"
        readinessProbe:
          httpGet:
            path: /health
            port: 3001
          initialDelaySeconds: 5
          periodSeconds: 10
        livenessProbe:
          httpGet:
            path: /health
            port: 3001
          initialDelaySeconds: 15
          periodSeconds: 20 