sso: retry keycloak secret jobs
This commit is contained in:
parent
728f2cd2ee
commit
acfab6a150
@ -2,7 +2,7 @@
|
|||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: Job
|
kind: Job
|
||||||
metadata:
|
metadata:
|
||||||
name: actual-oidc-secret-ensure-2
|
name: actual-oidc-secret-ensure-3
|
||||||
namespace: sso
|
namespace: sso
|
||||||
spec:
|
spec:
|
||||||
backoffLimit: 0
|
backoffLimit: 0
|
||||||
|
|||||||
@ -10,7 +10,7 @@ imagePullSecrets:
|
|||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: Job
|
kind: Job
|
||||||
metadata:
|
metadata:
|
||||||
name: mas-secrets-ensure-19
|
name: mas-secrets-ensure-20
|
||||||
namespace: sso
|
namespace: sso
|
||||||
spec:
|
spec:
|
||||||
backoffLimit: 0
|
backoffLimit: 0
|
||||||
@ -49,6 +49,13 @@ spec:
|
|||||||
umask 077
|
umask 077
|
||||||
|
|
||||||
KC_URL="http://keycloak.sso.svc.cluster.local"
|
KC_URL="http://keycloak.sso.svc.cluster.local"
|
||||||
|
for attempt in 1 2 3 4 5 6 7 8 9 10; do
|
||||||
|
if curl -fsS "${KC_URL}/realms/master" >/dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Waiting for Keycloak to be reachable (attempt ${attempt})" >&2
|
||||||
|
sleep $((attempt * 2))
|
||||||
|
done
|
||||||
ACCESS_TOKEN=""
|
ACCESS_TOKEN=""
|
||||||
for attempt in 1 2 3 4 5; do
|
for attempt in 1 2 3 4 5; do
|
||||||
TOKEN_JSON="$(curl -sS -X POST "$KC_URL/realms/master/protocol/openid-connect/token" \
|
TOKEN_JSON="$(curl -sS -X POST "$KC_URL/realms/master/protocol/openid-connect/token" \
|
||||||
|
|||||||
@ -5,6 +5,13 @@ set -euo pipefail
|
|||||||
|
|
||||||
KC_URL="http://keycloak.sso.svc.cluster.local"
|
KC_URL="http://keycloak.sso.svc.cluster.local"
|
||||||
ACCESS_TOKEN=""
|
ACCESS_TOKEN=""
|
||||||
|
for attempt in 1 2 3 4 5 6 7 8 9 10; do
|
||||||
|
if curl -fsS "${KC_URL}/realms/master" >/dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Waiting for Keycloak to be reachable (attempt ${attempt})" >&2
|
||||||
|
sleep $((attempt * 2))
|
||||||
|
done
|
||||||
for attempt in 1 2 3 4 5; do
|
for attempt in 1 2 3 4 5; do
|
||||||
TOKEN_JSON="$(curl -sS -X POST "$KC_URL/realms/master/protocol/openid-connect/token" \
|
TOKEN_JSON="$(curl -sS -X POST "$KC_URL/realms/master/protocol/openid-connect/token" \
|
||||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||||
@ -35,7 +42,7 @@ if [ -z "$CLIENT_ID" ] || [ "$CLIENT_ID" = "null" ]; then
|
|||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d "${create_payload}" \
|
-d "${create_payload}" \
|
||||||
"$KC_URL/admin/realms/atlas/clients")"
|
"$KC_URL/admin/realms/atlas/clients")"
|
||||||
if [ "$status" != "201" ] && [ "$status" != "204" ]; then
|
if [ "$status" != "201" ] && [ "$status" != "204" ] && [ "$status" != "409" ]; then
|
||||||
echo "Keycloak client create failed (status ${status})" >&2
|
echo "Keycloak client create failed (status ${status})" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user