
apiVersion: apps/v1
kind: Deployment
metadata:
  name: keycloak
  labels:
    run.armada/part-of: login
    run.armada/component: keycloack
    run.armada/tier: deployment
    run.armada/version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      run.armada/part-of: login
      run.armada/component: keycloack
      run.armada/tier: application
  strategy:
    type: Recreate
  template:
    metadata:
      name: keycloak
      labels:
        run.armada/part-of: login
        run.armada/component: keycloack
        run.armada/tier: application
        run.armada/version: v1
    spec:
      containers:
      - name: keycloak-container
        image: jboss/keycloak:3.4.2.Final
        ports:
        - name: http
          containerPort: 8080
        - name: management
          containerPort: 9090
        env:
        - name: KEYCLOAK_USER
          valueFrom: 
            secretKeyRef:
              name: keycloak-secret
              key: username
        - name: KEYCLOAK_PASSWORD
          valueFrom: 
            secretKeyRef:
              name: keycloak-secret
              key: password
        - name: PROXY_ADDRESS_FORWARDING
          value: "true"
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        readinessProbe:
          httpGet:
            path: /auth/realms/master
            port: 8080
        command:
        - /scripts/run.sh
        args: []
        volumeMounts:
          - name: keycloak-scripts
            mountPath: "/scripts"
            readOnly: true
      volumes:
      - name: keycloak-scripts
        projected:
          sources:
          - configMap:
              name: keycloak-scripts-configmap
              items:
              - key: REPLICAS
                path: REPLICAS
                mode: 0444
              - key: run.sh
                path: run.sh
                mode: 0755
              - key: standalone-ha.xml
                path: standalone-ha.xml
                mode: 0644

