apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: aro-hcp-backend
  name: aro-hcp-backend
spec:
  progressDeadlineSeconds: 600
  replicas: 2
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: aro-hcp-backend
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: aro-hcp-backend
        azure.workload.identity/use: "true"
    spec:
      serviceAccountName: backend
      containers:
      - name: aro-hcp-backend
        image: '{{ .Values.deployment.imageName }}'
        imagePullPolicy: Always
        args: ["--clusters-service-url", "http://clusters-service.{{ .Values.clustersService.namespace }}.svc.cluster.local:8000"]
        env:
        - name: DB_NAME
          valueFrom:
            configMapKeyRef:
              name: backend-config
              key: DB_NAME
        - name: DB_URL
          valueFrom:
            configMapKeyRef:
              name: backend-config
              key: DB_URL
        - name: LOCATION
          valueFrom:
            configMapKeyRef:
              name: backend-config
              key: LOCATION
        - name: NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        ports:
        - containerPort: 8081
          protocol: TCP
        - containerPort: 8083
          protocol: TCP
        resources:
          limits:
            memory: 1Gi
          requests:
            cpu: 100m
            memory: 500Mi
        securityContext:
          allowPrivilegeEscalation: false
          capabilities:
            drop:
            - ALL
          runAsNonRoot: true
          seccompProfile:
            type: RuntimeDefault
        readinessProbe:
          httpGet:
            path: /healthz
            port: 8083
          initialDelaySeconds: 5
          periodSeconds: 10
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
