With Hibernate, OpenShift clusters can be stopped and started by simply shutting down their machines and starting them back up
On the other hand, developers can view or programatically manage clusters through https://api.openshift.com/.
- Get an openshift offline token from https://console.redhat.com/openshift/token:
TOKEN="Grabbed from console.redhat.com/openshift/token"
- Use the Token to authenticate against Red Hat SSO to get the access_token:
AUTH_HEADER="Basic $(echo cloud-services: | base64)"
ACCESS_TOKEN=$(curl -H "Authorization: $AUTH_HEADER" -s https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token -d grant_type=refresh_token -d refresh_token=$TOKEN | jq -r .access_token)
- Get Access to the Clusters
curl -H "Authorization: Bearer $ACCESS_TOKEN" https://api.openshift.com/api/clusters_mgmt/v1/clusters | jq .
- Define the Cluster ID for the cluster
ID="xxxxxxxx"
- Hibernate the cluster
curl -v -X 'POST' -H "Authorization: Bearer $ACCESS_TOKEN" "https://api.openshift.com/api/clusters_mgmt/v1/clusters/${ID}/hibernate" | jq -r .
- Resume the Cluster state
curl -v -X 'POST' -H "Authorization: Bearer $ACCESS_TOKEN" "https://api.openshift.com/api/clusters_mgmt/v1/clusters/${ID}/resume" | jq -r .
- Login with the token obtained in https://console.redhat.com/openshift/token
ocm login --token=$TOKEN
- Check the status of the cluster:
ocm list clusters --no-headers | grep gcp | grep mobb
xxxxxxxx mobb-infra-gcp https://api.mobb-infra-gcp.xxxx.p2.openshiftapps.com:6443 4.10.13 osd gcp us-east1 running
- Extract the ID of the cluster
ID=$(ocm list clusters --no-headers | grep gcp | grep mobb | awk '{ print $1 }')
- Hibernate the Cluster using their ID
ocm hibernate cluster $ID
- Resume the Cluster using their ID
ocm resume cluster $ID