kubectl Commands - truongnhatbui/techtrends GitHub Wiki
Kubectl provides a rich set of actions that can be used to interact, manage, and configure Kubernetes resources. Below is a list of handy kubectl commands used in practice.
Note: In the following commands the following arguments are used:
- RESOURCE is the Kubernetes resource type
- NAME sets the name of the resource
- FLAGS are used to provide extra configuration
- PARAMS are used to provide the required configuration to the resource
Create Resources
To create resources, use the following command:
kubectl create RESOURCE NAME [FLAGS]
Describe Resources
To describe resources, use the following command:
kubectl describe RESOURCE NAME
Get Resources
To get resources, use the following command, where -o yaml instructs that the result should be YAML formated.
kubectl get RESOURCE NAME [-o yaml]
Edit Resources
To edit resources, use the following command, where -o yaml instructs that the edit should be YAML formated.
kubectl edit RESOURCE NAME [-o yaml]
Label Resources
To label resources, use the following command:
kubectl label RESOURCE NAME [PARAMS]
Port-forward to Resources
To access resources through port-forward, use the following command:
kubectl port-forward RESOURCE/NAME [PARAMS]
Logs from Resources
To access logs from a resource, use the following command:
kubectl logs RESOURCE/NAME [FLAGS]
Delete Resources
To delete resources, use the following command:
kubectl delete RESOURCE NAME