oc api-resources
is a convenient command which prints the supported API resources on the server. I usually use this command if I have to identify the scope of the API, whether it is namespaced or not. You can use this command, in combination with --namespaced=true
or --namespaced=false
. By default, this command will return all resources, but If you set it to true all namespace resources will be returned and vice versa.
For example, you can run the following command, which returns the API resources deployed in this cluster.
oc api-resources --namespaced=false --no-headers | wc -l
116
oc api-resources --namespaced=true --no-headers | wc -l
192
oc api-resources --no-headers | wc -l
308
Filter-based n API group
- Return all core API groups as follows,
oc api-resources --api-group=''
Output:
NAME SHORTNAMES APIVERSION NAMESPACED KIND
bindings v1 true Binding
componentstatuses cs v1 false ComponentStatus
configmaps cm v1 true ConfigMap
endpoints ep v1 true Endpoints
events ev v1 true Event
limitranges limits v1 true LimitRange
namespaces ns v1 false Namespace
nodes no v1 false Node
persistentvolumeclaims pvc v1 true PersistentVolumeClaim
persistentvolumes pv v1 false PersistentVolume
pods po v1 true Pod
podtemplates v1 true PodTemplate
replicationcontrollers rc v1 true ReplicationController
resourcequotas quota v1 true ResourceQuota
secrets v1 true Secret
serviceaccounts sa v1 true ServiceAccount
services svc v1 true Service
- Return all core-api groups which scope is global
oc api-resources --api-group='' --namespaced=false
Output:
NAME SHORTNAMES APIVERSION NAMESPACED KIND
componentstatuses cs v1 false ComponentStatus
namespaces ns v1 false Namespace
nodes no v1 false Node
persistentvolumes pv v1 false PersistentVolume
- use
-o
to specify the output format. It currently supports onlywide
andname
arguments.
oc api-resources --api-group policy -o wide
Output
NAME SHORTNAMES APIVERSION NAMESPACED KIND VERBS
poddisruptionbudgets pdb policy/v1 true PodDisruptionBudget [create delete deletecollection get list patch update watch]
podsecuritypolicies psp policy/v1beta1 false PodSecurityPolicy [create delete deletecollection get list patch update watch]
- You can sort the output by
name
orkind
oc api-resources --api-group "" -o name --namespaced=false --sort-by=name
Output:
componentstatuses
namespaces
nodes
persistentvolumes
Discussion (0)