# at namespace level
oc api-resources --namespaced=true
# at cluster level
oc api-resources --namespaced=false
oc explain bc
oc explain bc.spec
oc explain bc.spec.completionDeadlineSeconds
oc explain dc
oc explain dc.spec
oc explain dc.spec.template
oc explain dc.spec.template.spec
oc explain dc.spec.template.spec.volumes
oc get pod/<pod> -o custom-columns=namespace:metadata.namespace,name:metadata.name,nodeName:spec.nodeName
oc get route --all-namespaces -o json | jq '.items[] | select ( .status.ingress[].conditions[] | .type == "Admitted" and .status == "False")'
## Prettier output (columns)
oc get route --all-namespaces -o json | jq -r '["namespace", "name", "reason"], (.items[] | select ( .status.ingress[].conditions[] | .type == "Admitted" and .status == "False") | [.metadata.namespace, (.kind +"/"+.metadata.name), ( .status.ingress[].conditions[].reason)]) | @csv' | column -ts,
# as of 3.9
oc get '--raw=/apis?limit=500' | jq -crM '.groups[] | .preferredVersion.groupVersion' | ( xargs -I {} oc get '--raw=/apis/{}?limit=500' | jq -crM '.resources[] | select(.categories | values | .[] | . == "all" ) | .name' )
Reference: openshift/origin#18396 (comment)
oc get '--raw=/apis?limit=500' | jq -crM '.groups[] | .preferredVersion.groupVersion' | ( xargs -I {} oc get '--raw=/apis/{}?limit=500' | jq -crM '.resources[] | .name' )
oc get project -o custom-columns=name:.metadata.name,project-set:.metadata.labels.name,product:.metadata.labels.product,product-owner:.metadata.annotations.product-owner,product-lead:.metadata.annotations.product-lead
oc get project -o custom-columns=NAME:.metadata.name,PROJECT-SET:.metadata.labels.name,DISPLAY-NAME:.metadata.annotations.openshift.io/display-name
oc get project -o 'custom-columns=NAME:.metadata.name,PROJECT-SET:.metadata.labels.name,TEAM:.metadata.labels.team,DISPLAY-NAME:.metadata.annotations.openshift\.io/display-name'
oc get project -o 'custom-columns=NAME:.metadata.name,PROJECT-SET:.metadata.labels.name,TEAM:.metadata.labels.team,MCIO:.metadata.labels.mcio,DISPLAY-NAME:.metadata.annotations.openshift\.io/display-name'
oc get pvc -o custom-columns=namesapce:.metadata.namespace --no-headers --all-namespaces | sort | uniq -c | sort -n
#currently selected project/namespace
# Option 1
oc get imagestreams -o json | jq -r '.items[] | {imageStream:.metadata.name, image:.status.tags[]?.items[].image} | (.imageStream + "@" + .image)' | xargs -I {} oc get 'imagestreamimage/{}' -o json | jq -r '.image.dockerImageLayers[] | (.name + "\t" + (.size | tostring))' | sort | uniq | awk '{ sum += $2 } END { print sum }' | awk '{ foo = $1 / 1024 / 1024 / 1024 ; print foo "GB" }'
# Option 2
oc get imagestreams -o json | jq -r '.items[] | {imageStream:.metadata.name, image:.status.tags[]?.items[].image} | (.imageStream + "@" + .image)' | xargs -I {} oc get 'imagestreamimage/{}' -o json | jq -r '.image.dockerImageLayers[] | {name: .name, size: .size}' | jq -sr 'unique_by(.name) | .[].size' | awk '{ sum += $1 } END { print (sum / 1024 / 1024 / 1024) "GB" }'