apiVersion: v1
kind: ServiceAccount
metadata:
  name: products
  namespace: products
  annotations:
    azure.workload.identity/client-id: ${PRODUCTS_CLIENT_ID}
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: bootstrap
  namespace: products
data:
  APP_CONFIG_ENDPOINT: ${APP_CONFIG_ENDPOINT}
  APP_CONFIG_LABEL: workshop
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: products
  namespace: products
spec:
  replicas: 1
  selector:
    matchLabels: {app: products}
  template:
    metadata:
      labels:
        app: products
        azure.workload.identity/use: "true"
    spec:
      serviceAccountName: products
      securityContext: {runAsNonRoot: true, runAsUser: 10001, runAsGroup: 10001, fsGroup: 10001}
      containers:
        - name: products
          image: ${ACR_HOST}/products:${IMAGE_TAG}
          imagePullPolicy: IfNotPresent
          envFrom: [{configMapRef: {name: bootstrap}}]
          env:
            - {name: SPRING_PROFILES_ACTIVE, value: azure}
          ports: [{name: https, containerPort: 8443}]
          resources:
            requests: {cpu: 500m, memory: 768Mi}
            limits: {cpu: "2", memory: 1536Mi}
          startupProbe:
            httpGet: {path: /actuator/health/readiness, port: https, scheme: HTTPS}
            failureThreshold: 60
            periodSeconds: 5
          readinessProbe:
            httpGet: {path: /actuator/health/readiness, port: https, scheme: HTTPS}
          livenessProbe:
            httpGet: {path: /actuator/health/liveness, port: https, scheme: HTTPS}
          securityContext: {allowPrivilegeEscalation: false, capabilities: {drop: [ALL]}}
          volumeMounts: [{name: tls, mountPath: /tls, readOnly: true}]
      volumes: [{name: tls, secret: {secretName: products-tls, defaultMode: 0440}}]
