Skip to content

Instantly share code, notes, and snippets.

@psturc
Created March 17, 2021 11:56
Show Gist options
  • Save psturc/f1e35bbeba3eba25da04cc2d7551cae2 to your computer and use it in GitHub Desktop.
Save psturc/f1e35bbeba3eba25da04cc2d7551cae2 to your computer and use it in GitHub Desktop.
read keycloak statefulsets and save the data in json with timestamp
{
"rhsso": [],
"usersso": []
}
#!/usr/bin/env bash
STATUS_FILENAME="sso-status-during-upgrade.json"
TMP_FILE="status.tmp"
PAUSE_TIME_VALUE=2
while true
do
# RHSSO
echo "Getting RHSSO stateful set..."
jq ".rhsso[.rhsso | length] |= . + $(oc get statefulset keycloak -n redhat-rhoam-rhsso -o json | jq -r ".timestamp = \"$(date '+%T')\"")" < $STATUS_FILENAME > $TMP_FILE
mv $TMP_FILE $STATUS_FILENAME
# User SSO
echo "Getting User-SSO stateful set..."
jq ".usersso[.usersso | length] |= . + $(oc get statefulset keycloak -n redhat-rhoam-user-sso -o json | jq -r ".timestamp = \"$(date '+%T')\"")" < $STATUS_FILENAME > $TMP_FILE
mv $TMP_FILE $STATUS_FILENAME
echo "Sleeping for $PAUSE_TIME_VALUE seconds..."
sleep $PAUSE_TIME_VALUE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment