Created
July 15, 2019 19:30
-
-
Save jharrington22/1b4531ba2b2e28648191784a8b571436 to your computer and use it in GitHub Desktop.
Update kubernetes status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/ | |
# Update status | |
# List cluster context names `kubectl config view -o jsonpath='{"Cluster name\tServer\n"}{range .clusters[*]}{.name}{"\t"}{.cluster.server}{"\n"}{end}'` | |
CLUSTER_NAME="192-168-99-100:8443" | |
APISERVER=$(kubectl config view -o jsonpath="{.clusters[?(@.name==\"$CLUSTER_NAME\")].cluster.server}") | |
# Service account for aws-account-operator in the aws-account-operator namespace | |
# `oc get secrets -n aws-account-operator` look for aws-account-operator-token-<some id> | |
AAO_SERVICE_ACCOUNT_NAME="aws-account-operator-token-s87z6" | |
TOKEN=$(oc get secret "${AAO_SERVICE_ACCOUNT_NAME}" -n aws-account-operator -o json | jq -r '.data.token' | base64 -d) | |
ACCOUNT_CR_NAME="osd-creds-mgmt-dx454h" | |
RETURN_CODE=$(curl -s -I -X GET $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure | grep -oE "HTTP\/2\ +[0-9]{3}") | |
if ! [ "$RETURN_CODE" = 'HTTP/2 200' ]; then | |
echo "Return code: $RETURN_CODE" | |
echo "Authentication failure?" | |
exit 1 | |
fi | |
PATCH_DATA='[{"op": "add", "path": "/status/rotateCredentials", "value": false}]' | |
curl --header "Content-Type: application/json-patch+json" \ | |
--header "Authorization: Bearer $TOKEN" \ | |
--request PATCH \ | |
--insecure \ | |
--data "${PATCH_DATA}" \ | |
"${APISERVER}"/apis/aws.managed.openshift.io/v1alpha1/namespaces/aws-account-operator/accounts/"${ACCOUNT_CR_NAME}"/status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment