Check status of Ironic baremetal nodes in OpenShift cluster
Retrieves and displays the status of Ironic baremetal nodes in an OpenShift cluster.
/plugin marketplace add openshift-eng/ai-helpers/plugin install openshift@ai-helpersopenshift:ironic-status
/openshift:ironic-status
The openshift:ironic-status command checks the status of Ironic baremetal nodes in an OpenShift cluster.
This command is useful for:
Before using this command, ensure you have:
OpenShift CLI (oc): Must be installed and configured
oc versionActive cluster connection: Must be connected to an OpenShift cluster with baremetal nodes
oc whoamiSufficient permissions: Must have access to the openshift-machine-api namespace
baremetal cluster: The cluster must be running on baremetal infrastructure with Metal3/Ironic enabled
oc get pods -n openshift-machine-api | grep metal3-ironicThe command performs the following steps to retrieve Ironic node status:
Locate the Ironic service in the openshift-machine-api namespace:
# Find the Ironic service (typically named metal3-state)
oc get service -n openshift-machine-api metal3-state
# Get the ClusterIP of the Ironic service
IRONIC_SERVICE=$(oc get service -n openshift-machine-api metal3-state)
IRONIC_IP=$(oc get service -n openshift-machine-api $IRONIC_SERVICE -o jsonpath='{.spec.clusterIP}')
# Ironic API typically runs on port 6385
IRONIC_ENDPOINT="https://localhost:6385"
Extract authentication credentials from the baremetal operator container:
# Find the metal3-baremetal-operator pod
BAREMETAL_OPERATOR_POD=$(oc get pods -n openshift-machine-api -l baremetal.openshift.io/cluster-baremetal-operator=metal3-baremetal-operator -o jsonpath='{.items[0].metadata.name}')
# Extract username from the mounted auth volume
IRONIC_USERNAME=$(oc exec -n openshift-machine-api $BAREMETAL_OPERATOR_POD -c metal3-baremetal-operator -- cat /auth/ironic/username)
# Extract password from the mounted auth volume
IRONIC_PASSWORD=$(oc exec -n openshift-machine-api $BAREMETAL_OPERATOR_POD -c metal3-baremetal-operator -- cat /auth/ironic/password)
Execute the baremetal client command to retrieve node status:
# Find the metal3-ironic pod
# Example: oc get pods -n openshift-machine-api
# Output may show: metal3-65bd97647f-hbd48
# Execute baremetal node list command
oc exec -n openshift-machine-api $METAL3_POD -c metal3-ironic -- \
baremetal \
--os-cacert /certs/ironic/tls.crt
--os-auth-type http_basic \
--os-username "$IRONIC_USERNAME" \
--os-password "$IRONIC_PASSWORD" \
--os-endpoint "$IRONIC_ENDPOINT" \
node list
The output typically includes:
Handle common error scenarios:
# Check if Metal3 components are running
if ! oc get pods -n openshift-machine-api | grep -q metal3; then
echo "Error: Metal3 components not found. This may not be a baremetal cluster."
exit 1
fi
# Check if credentials were retrieved successfully
if [ -z "$IRONIC_USERNAME" ] || [ -z "$IRONIC_PASSWORD" ]; then
echo "Error: Failed to retrieve Ironic credentials"
exit 1
fi
# Handle connection failures
if ! oc exec ... 2>&1 | grep -q "UUID"; then
echo "Error: Failed to connect to Ironic API"
echo "Check that the Ironic service is accessible"
exit 1
fi
If expected values don't match your environment, use these techniques to discover the correct values:
If port 6385 doesn't work, discover the actual port:
# Check service ports
oc get service -n openshift-machine-api metal3-state -o jsonpath='{.spec.ports[*].port}'
# Then update IRONIC_ENDPOINT
IRONIC_ENDPOINT="https://localhost:${DISCOVERED_PORT}"
If service/pod names differ from expected patterns:
# List all services/pods in the namespace
oc get services -n openshift-machine-api
oc get pods -n openshift-machine-api
# Filter by labels
oc get services -n openshift-machine-api -l app=metal3
oc get pods -n openshift-machine-api -l app=metal3 -o jsonpath='{.items[0].metadata.name}'
If container names or credential paths are different:
# List containers in a pod
oc get pod -n openshift-machine-api <pod-name> -o jsonpath='{.spec.containers[*].name}'
# Find credential files
oc exec -n openshift-machine-api $POD -c $CONTAINER -- find /auth -type f 2>/dev/null
If baremetal command is unavailable, try:
# Check what's available
oc exec -n openshift-machine-api $METAL3_POD -c metal3-ironic -- which openstack
# Try alternatives: "openstack baremetal node list" or "ironic node-list"
# Or use curl directly
oc exec -n openshift-machine-api $METAL3_POD -c metal3-ironic -- \
curl -k -u "$IRONIC_USERNAME:$IRONIC_PASSWORD" "$IRONIC_ENDPOINT/v1/nodes"
General strategy: When commands fail, list resources with oc get, check labels with -l, inspect with oc describe, and explore interactively with oc exec.
The command outputs a table with the following columns:
Example output:
+--------------------------------------+------------------------+--------------------------------------+-------------+--------------------+-------------+
| UUID | Name | Instance UUID | Power State | Provisioning State | Maintenance |
+--------------------------------------+------------------------+--------------------------------------+-------------+--------------------+-------------+
| 12345678-1234-1234-1234-123456789012 | openshift-worker-0 | abcdef12-3456-7890-abcd-ef1234567890 | power on | active | False |
| 23456789-2345-2345-2345-234567890123 | openshift-worker-1 | bcdef123-4567-8901-bcde-f12345678901 | power on | active | False |
| 34567890-3456-3456-3456-345678901234 | openshift-worker-2 | None | power off | available | False |
+--------------------------------------+------------------------+--------------------------------------+-------------+--------------------+-------------+
Exit codes:
/openshift:ironic-status
Output:
Detecting Ironic endpoint...
Found Ironic service: metal3-state at 172.30.123.45:6385
Retrieving Ironic credentials...
Successfully retrieved credentials from baremetal operator
Querying Ironic node list...
+--------------------------------------+------------------------+--------------------------------------+-------------+--------------------+-------------+
| UUID | Name | Instance UUID | Power State | Provisioning State | Maintenance |
+--------------------------------------+------------------------+--------------------------------------+-------------+--------------------+-------------+
| 12345678-1234-1234-1234-123456789012 | openshift-worker-0 | abcdef12-3456-7890-abcd-ef1234567890 | power on | active | False |
| 23456789-2345-2345-2345-234567890123 | openshift-worker-1 | bcdef123-4567-8901-bcde-f12345678901 | power on | active | False |
| 34567890-3456-3456-3456-345678901234 | openshift-worker-2 | None | power off | available | False |
+--------------------------------------+------------------------+--------------------------------------+-------------+--------------------+-------------+
Summary: 3 nodes total (2 active, 1 available)
Understanding the provisioning states:
If Metal3 components are not running:
oc get pods -n openshift-machine-api
# Look for pods starting with 'metal3-'
# Check BareMetalHost resources
oc get baremetalhosts -n openshift-machine-api
If unable to retrieve credentials:
# Check if the secret exists
oc get secrets -n openshift-machine-api | grep metal3
# Verify the baremetal operator pod is running
oc get pods -n openshift-machine-api -l k8s-app=metal3-baremetal-operator
If unable to connect to Ironic API:
# Check if the Ironic pod is running
oc get pods -n openshift-machine-api -l app=metal3
# Check Ironic logs
oc logs -n openshift-machine-api <metal3-pod-name> -c metal3-ironic
/openshift:cluster-health-check