“kubectl api-resources”: The best kubectl command

Matías Salinas
3 min readMar 20, 2023

--

Kubernetes is a popular open-source container orchestration platform that allows users to manage containerized workloads in a scalable and automated manner. Kubernetes API is a critical component of this platform that enables users to interact with the system and perform various operations using API calls.

One of the essential commands for working with Kubernetes API is “kubectl api-resources.” It is a powerful tool that enables users to view all the supported resource types in the Kubernetes API(including custom resources). This command is handy when working with complex applications that rely on different resources, and you need to identify the available resources.

Using the “kubectl api-resources” Command

The “kubectl api-resources” command is easy to use and provides a comprehensive list of all resources supported by the Kubernetes API. To run the command, simply open your terminal and type:

$kubectl api-resources

When you run the command, the output displays all the available resources in your Kubernetes cluster. Each resource is displayed with its name, short name, API group, and whether it is namespaced or not.

Here is an example of the output you might see after running the command:

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
mutatingwebhookconfigurations admissionregistration.k8s.io/v1 false MutatingWebhookConfiguration
validatingwebhookconfigurations admissionregistration.k8s.io/v1 false ValidatingWebhookConfiguration
customresourcedefinitions crd,crds apiextensions.k8s.io/v1 false CustomResourceDefinition
apiservices apiregistration.k8s.io/v1 false APIService
controllerrevisions apps/v1 true ControllerRevision
daemonsets ds apps/v1 true DaemonSet
deployments deploy apps/v1 true Deployment
replicasets rs apps/v1 true ReplicaSet
statefulsets sts apps/v1 true StatefulSet
tokenreviews authentication.k8s.io/v1 false TokenReview
localsubjectaccessreviews authorization.k8s.io/v1 true LocalSubjectAccessReview
selfsubjectaccessreviews authorization.k8s.io/v1 false SelfSubjectAccessReview
selfsubjectrulesreviews authorization.k8s.io/v1 false SelfSubjectRulesReview
subjectaccessreviews authorization.k8s.io/v1 false SubjectAccessReview
allowlistedworkloads auto.gke.io/v1 false AllowlistedWorkload
horizontalpodautoscalers hpa autoscaling/v2 true HorizontalPodAutoscaler
cronjobs cj batch/v1 true CronJob
jobs batch/v1 true Job
certificatesigningrequests csr certificates.k8s.io/v1 false CertificateSigningRequest
containerwatcherstatuses containerthreatdetection.googleapis.com/v1 true ContainerWatcherStatus
leases coordination.k8s.io/v1 true Lease
endpointslices discovery.k8s.io/v1 true EndpointSlice
events ev events.k8s.io/v1 true Event
wasmplugins extensions.istio.io/v1alpha1 true WasmPlugin
flowschemas flowcontrol.apiserver.k8s.io/v1beta2 false FlowSchema
prioritylevelconfigurations flowcontrol.apiserver.k8s.io/v1beta2 false PriorityLevelConfiguration
memberships hub.gke.io/v1 false Membership
istiooperators iop,io install.istio.io/v1alpha1 true IstioOperator
capacityrequests capreq internal.autoscaling.gke.io/v1alpha1 true CapacityRequest
nodes metrics.k8s.io/v1beta1 false NodeMetrics
pods metrics.k8s.io/v1beta1 true PodMetrics
destinationrules dr networking.istio.io/v1beta1 true DestinationRule
envoyfilters networking.istio.io/v1alpha3 true EnvoyFilter
gateways gw networking.istio.io/v1beta1 true Gateway
serviceentries se networking.istio.io/v1beta1 true ServiceEntry
sidecars networking.istio.io/v1beta1 true Sidecar
virtualservices vs networking.istio.io/v1beta1 true VirtualService
workloadentries we networking.istio.io/v1beta1 true WorkloadEntry
workloadgroups wg networking.istio.io/v1alpha3 true WorkloadGroup
ingressclasses networking.k8s.io/v1 false IngressClass
ingresses ing networking.k8s.io/v1 true Ingress
networkpolicies netpol networking.k8s.io/v1 true NetworkPolicy
runtimeclasses node.k8s.io/v1 false RuntimeClass
updateinfos updinf nodemanagement.gke.io/v1alpha1 true UpdateInfo
poddisruptionbudgets pdb policy/v1 true PodDisruptionBudget
podsecuritypolicies psp policy/v1beta1 false PodSecurityPolicy
clusterrolebindings rbac.authorization.k8s.io/v1 false ClusterRoleBinding
clusterroles rbac.authorization.k8s.io/v1 false ClusterRole
rolebindings rbac.authorization.k8s.io/v1 true RoleBinding
roles rbac.authorization.k8s.io/v1 true Role
priorityclasses pc scheduling.k8s.io/v1 false PriorityClass
authorizationpolicies security.istio.io/v1beta1 true AuthorizationPolicy
peerauthentications pa security.istio.io/v1beta1 true PeerAuthentication
requestauthentications ra security.istio.io/v1beta1 true RequestAuthentication
volumesnapshotclasses snapshot.storage.k8s.io/v1 false VolumeSnapshotClass
volumesnapshotcontents snapshot.storage.k8s.io/v1 false VolumeSnapshotContent
volumesnapshots snapshot.storage.k8s.io/v1 true VolumeSnapshot
csidrivers storage.k8s.io/v1 false CSIDriver
csinodes storage.k8s.io/v1 false CSINode
csistoragecapacities storage.k8s.io/v1 true CSIStorageCapacity
storageclasses sc storage.k8s.io/v1 false StorageClass
volumeattachments storage.k8s.io/v1 false VolumeAttachment
telemetries telemetry telemetry.istio.io/v1alpha1 true Telemetry

The output consists of several columns, each of which provides essential information about the resource. The columns are:

  • NAME: The name of the resource.
  • SHORTNAMES: The abbreviated name of the resource.
  • APIGROUP: The API group of the resource.
  • NAMESPACED: Indicates whether the resource is namespaced or not.
  • KIND: The type of Kubernetes object that represents the resource.

Conclusion

The “kubectl api-resources” command is an essential tool for managing Kubernetes clusters. It provides a comprehensive list of all supported resources and their properties, which can help you better understand your application’s architecture and dependencies. Whether you are a beginner or an experienced Kubernetes user, mastering this command can help you work more efficiently and effectively with Kubernetes API.

--

--

Matías Salinas
Matías Salinas

No responses yet