If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.
A node contains one or more pods, and each pod contains one or more containers.
The oc get pod command with one of the following options can be used to display the pods JSON or YAML.
oc get pod foo-67b6d87679-vmzmz -o yaml
Something like this should be returned.
apiVersion: v1
kind: Pod
metadata:
annotations:
k8s.v1.cni.cncf.io/network-status: |-
[{
"name": "",
"interface": "eth0",
"ips": [
"10.16.9.49"
],
"default": true,
"dns": {}
}]
openshift.io/scc: restricted
creationTimestamp: "2022-02-02T17:28:53Z"
generateName: foo-67b6d87679-
Or like this, using JSON.
~]$ oc get pod php-73-rhel7-cf8fc698-zfjc5 --output json
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"creationTimestamp": "2022-06-24T01:39:22Z",
"generateName": "php-73-rhel7-cf8fc698-",
"labels": {
"deployment": "php-73-rhel7",
"pod-template-hash": "cf8fc698"
},
jsonpath can be used to print the value of a specific JSON key.
~]$ oc get pod php-73-rhel7-cf8fc698-zfjc5 --output jsonpath={.apiVersion}
v1
And like this, iterating through keys and arrays.
~]$ oc get pod php-73-rhel7-cf8fc698-zfjc5 --output jsonpath={.spec.containers[0].image}
registry.redhat.io/rhscl/php-73-rhel7@sha256:6811b96e48f7b3dc034be1fe2e3f598fbcddc20d6b3c3224bc67cea0d2b14a70