# services/keycloak/bootstrap-jobs/hermes-access-oidc-client-job.yaml
# Purpose: create isolated chat, Brad-only agent, and Brad-only triage clients.
apiVersion: batch/v1
kind: Job
metadata:
  name: hermes-access-oidc-client-ensure-5
  namespace: sso
spec:
  backoffLimit: 3
  template:
    metadata:
      annotations:
        vault.hashicorp.com/agent-inject: "true"
        vault.hashicorp.com/agent-pre-populate-only: "true"
        vault.hashicorp.com/role: sso-secrets
        vault.hashicorp.com/agent-inject-secret-keycloak-admin-env.sh: kv/data/atlas/shared/keycloak-admin
        vault.hashicorp.com/agent-inject-template-keycloak-admin-env.sh: |
          {{ with secret "kv/data/atlas/shared/keycloak-admin" }}
          export KEYCLOAK_ADMIN="{{ .Data.data.username }}"
          export KEYCLOAK_ADMIN_USER="{{ .Data.data.username }}"
          export KEYCLOAK_ADMIN_PASSWORD="{{ .Data.data.password }}"
          {{ end }}
    spec:
      serviceAccountName: mas-secrets-ensure
      restartPolicy: Never
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: kubernetes.io/arch
                    operator: In
                    values:
                      - arm64
                  - key: node-role.kubernetes.io/worker
                    operator: Exists
                  - key: kubernetes.io/hostname
                    operator: NotIn
                    values:
                      - titan-18
      containers:
        - name: apply
          image: bitnami/kubectl@sha256:554ab88b1858e8424c55de37ad417b16f2a0e65d1607aa0f3fe3ce9b9f10b131
          command:
            - /scripts/hermes_access_oidc_ensure.sh
          volumeMounts:
            - name: script
              mountPath: /scripts
              readOnly: true
          resources:
            requests:
              cpu: 25m
              memory: 32Mi
            limits:
              cpu: 250m
              memory: 128Mi
      volumes:
        - name: script
          configMap:
            name: hermes-access-oidc-script
            defaultMode: 0555
