apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: keycloak
  labels:
    app.kubernetes.io/name: keycloak
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: keycloak
  serviceName: keycloak
  replicas: 1
  template:
    metadata:
      labels:
        app.kubernetes.io/name: keycloak
    spec:
      containers:
        - name: keycloak
          image: quay.io/keycloak/keycloak:16.1.0
          imagePullPolicy: "Always"
          env:
            - name: KEYCLOAK_USER
              value: "admin"
            - name: KEYCLOAK_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: adminpassword
                  name: keycloak
          ports:
            - name: tcp-keycloak
              containerPort: 8080
          startupProbe:
            exec:
              command: 
                - /bin/sh
                - -x
                - -c
                - curl -s http://localhost:8080 | grep 'If you are not redirected automatically, follow this'
            failureThreshold: 30
            periodSeconds: 10
#        - name: netshoot
#          command: [ 'tail', '-f', '/dev/null' ]
#          image: docker.io/nicolaka/netshoot:latest
#          imagePullPolicy: "Always"
