kubectl resource type specification¶
The resource type (TYPE) in kubectl syntax specifies the Kubernetes object type (e.g., Pod, Service) upon which an operation should be performed^[400-devops-06-kubernetes-k8s-ithelp-day11-readme.md].
Syntax Specification¶
The TYPE parameter is part of the standard kubectl invocation syntax:^[400-devops-06-kubernetes-k8s-ithelp-day11-readme.md]
[kubectl](<./kubectl.md>) [command] [TYPE] [NAME] [flags]
This parameter accepts the singular, plural, or abbreviated form of the resource type, and it is case-insensitive^[400-devops-06-kubernetes-k8s-ithelp-day11-readme.md].
Examples of Variations¶
For example, when interacting with a pod, the following commands are equivalent:^[400-devops-06-kubernetes-k8s-ithelp-day11-readme.md]
[kubectl](<./kubectl.md>) get [Pod](<./pod.md>) pod1
[kubectl get pods](<./kubectl-get-pods.md>) pod1
[kubectl](<./kubectl.md>) get po pod1
This flexibility also applies to other resources. For a service, you may use service, services, or the abbreviation svc^[400-devops-06-kubernetes-k8s-ithelp-day11-readme.md]. Similarly, deployment can be specified as deployment, deployments, or deploy^[400-devops-06-kubernetes-k8s-ithelp-day11-readme.md].
Specifying Multiple Resources¶
The TYPE field allows for complex grouping and selection of resources to manage multiple items in a single command^[400-devops-06-kubernetes-k8s-ithelp-day11-readme.md].
- Same type, multiple names: To target specific resources of the same type, list the names sequentially:^[400-devops-06-kubernetes-k8s-ithelp-day11-readme.md]
TYPE1 name1 name2 name<#>- Example:
kubectl get [Pod](<./pod.md>) example-pod1 example-pod2
- Example:
- Different types: To target specific resources of different types, use the
TYPE/namesyntax separated by spaces:^[400-devops-06-kubernetes-k8s-ithelp-day11-readme.md]TYPE1/name1 TYPE2/name2- Example:
kubectl get [Pod](<./pod.md>)/example-pod1 replicationcontroller/example-rc1
- Example:
- From files: Instead of declaring types explicitly, resources can be specified from one or more files using the
-fflag:^[400-devops-06-kubernetes-k8s-ithelp-day11-readme.md]kubectl get -f ./[Pod](<./pod.md>).yaml
Sources¶
^[400-devops-06-kubernetes-k8s-ithelp-day11-readme.md]