Verify the cluster status by inspecting cluster services. Format command outputs by using filters.
Retrieve the list of pods for the Etcd operator. The Etcd operator is available in the openshift-etcd namespace. Specify the namespace with the --namespace or -n option.
[student@workstation ~]$ oc get pods -n openshift-etcd
Error from server (Forbidden): pods is forbidden: User "developer" cannot list resource "pods" in API group "" in the namespace "openshift-etcd"
The developer user cannot access resources in the openshift-etcd namespace. Regular cluster users, such as the developer user, cannot query resources in the openshift- namespaces.
Log in as the admin user with the redhatocp password. Then, retrieve the list of pods in the openshift-etcd namespace.
[student@workstation ~]$ oc login -u admin -p redhatocp
Login successful
...output omitted...
[student@workstation ~]$ oc get pods -n openshift-etcd
NAME READY STATUS RESTARTS AGE
etcd-master01 4/4 Running 36 25d
installer-2-master01 0/1 Completed 0 25d
installer-3-master01 0/1 Completed 0 25d
Retrieve the conditions status of the etcd-master01 pod in the openshift-etcd namespace. Use filters to limit the output to the .status.conditions attribute of the pod. Compare the outputs of the JSONPath and jq filters.
[student@workstation ~]$ oc get pods etcd-master01 -n openshift-etcd \
-o=jsonpath='{.status.conditions}{"\n"}'
[{"lastProbeTime":null,"lastTransitionTime":"2023-03-07T18:05:13Z",
"status":"True","type":"Initialized"},{"lastProbeTime":null,
"lastTransitionTime":"2023-03-07T18:05:28Z","status":"True","type":"Ready"},
{"lastProbeTime":null,"lastTransitionTime":"2023-03-07T18:05:28Z",
"status":"True","type":"ContainersReady"},
{"lastProbeTime":null,"lastTransitionTime":"2023-03-07T18:05:06Z",
"status":"True","type":"PodScheduled"}]
[student@workstation ~]$ oc get pods -n openshift-etcd etcd-master01 \
-o json | jq .status.conditions
[
{
"lastProbeTime": null,
"lastTransitionTime": "2023-03-07T18:05:13Z",
"status": "True",
"type": "Initialized"
},
{
"lastProbeTime": null,
"lastTransitionTime": "2023-03-07T18:05:28Z",
"status": "True",
"type": "Ready"
},
{
"lastProbeTime": null,
"lastTransitionTime": "2023-03-07T18:05:28Z",
"status": "True",
"type": "ContainersReady"
},
{
"lastProbeTime": null,
"lastTransitionTime": "2023-03-07T18:05:06Z",
"status": "True",
"type": "PodScheduled"
}
]
Using the JSON format and the jq filter provides a structured output for the .status.conditions attribute.
Retrieve the condition status of the prometheus-k8s-0 pod in the openshift-monitoring namespace. Configure the output to use the YAML format, and then filter the output with the yq filter.
[student@workstation ~]$ oc get pods -n openshift-monitoring prometheus-k8s-0 \
-o yaml | yq r - 'status.conditions'
- lastProbeTime: null
lastTransitionTime: "2023-03-07T18:07:17Z"
status: "True"
type: Initialized
- lastProbeTime: null
lastTransitionTime: "2023-03-07T18:07:45Z"
status: "True"
type: Ready
- lastProbeTime: null
lastTransitionTime: "2023-03-07T18:07:45Z"
status: "True"
type: ContainersReady
- lastProbeTime: null
lastTransitionTime: "2023-02-09T22:39:52Z"
status: "True"
type: PodScheduled
The r - option tells the yq command to read the standard input (STDIN) for the YAML output of the get command.
Use the get command to retrieve detailed information for the pods in the openshift-storage namespace. Use the YAML format and custom columns to filter the output according to the following table:
| Column title | Object |
| --- | --- |
| Pod | metadata.name |
| API | apiVersion |
| Container | spec.containers[].name |
| Phase | status.phase |
| IP | status.podIP |
| Ports | spec.containers[].ports[].containerPort |
[student@workstation ~]$ oc get pods -n openshift-storage -o yaml \
-o custom-columns=PodName:".metadata.name",\
ContainerName:"spec.containers[].name",\
Phase:"status.phase",\
IP:"status.podIP",\
Ports:"spec.containers[].ports[].containerPort"
PodName ContainerName Phase IP Ports
lvm-operator-controller-... kube-rbac-proxy Running 10.8.0.97 8443
topolvm-controller-.... topolvm-controller Running 10.8.0.98 9808
topolvm-node-9spzf lvmd Running 10.8.0.100 <none>
vg-manager-z8g5k vg-manager Running 10.8.0.101 <none>