Skip to content

Instantly share code, notes, and snippets.

@jgato
Last active January 5, 2023 11:47
Show Gist options
  • Save jgato/8d0b50bc521873431942b2fa01357665 to your computer and use it in GitHub Desktop.
Save jgato/8d0b50bc521873431942b2fa01357665 to your computer and use it in GitHub Desktop.
Find out the Agent object corresponding to a BMH
# It returns all the BMH of an spoke cluster
# and its corresponding Agent
# it could be useful when scaling down a cluster with ZTP
# ZTP only controls (and delete) the BMH object
# but the Agent is not under the Gitops control
# and it has to be manually deleted
oc -n <SPOKE_CLUSTER_NS> get Agent.agent-install.openshift.io -o json \
| jq '.items[].metadata | "BMH resource: " + .labels."agent-install.openshift.io/bmh" + " with Agent: " + .name '
# or directly get the agent of a BMH
oc -n <SPOKE_CLUSTER_NS> get Agent.agent-install.openshift.io -o json \
| jq '.items[].metadata | select(.labels."agent-install.openshift.io/bmh"=="<DELETED_BMH_NAME>") | .name'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment