Command KUBECTLKUBECTL output format
- Show pod for more information
kubectl get pod <pod-name> -o wide
- Show pod details in YAML format
kubectl get pod <pod-name> -o yaml
Kubectl Operation Example 1. Create a Resource object
- Create service and RC at once based on Yaml configuration file
kubectl create -f my-service.yaml -f my-rc.yaml
<directory>create operations based on the definition of all. Yaml,. yml,. json files in the directory
kubectl create -f <directory>
2. View Resource Objects
- View All Pod Listings
kubectl get pods
- View RC and Service lists
kubectl get rc,service
3. Describe the resource object
- Show Node's details
kubectl describe nodes <node-name>
- Show pod Details
kubectl describe pods/<pod-name>
- Display information for pods managed by RC
kubectl describe pods <rc-name>
4. Delete a Resource object
- Delete pod based on the name of the POD.YAML definition
kubectl delete -f pod.yaml
- Remove all pods and service that contain a label
kubectl delete pods,services -l name=<label-name>
- Delete all Pods
kubectl delete pods --all
5. Command to execute a container
- The data command to execute the pod, which is performed by default with the first container in the pod
kubectl exec <pod-name> data
- Specify a container in the pod to execute the data command
kubectl exec <pod-name> -c <container-name> data
- Use bash to get a TTY for a container in the pod, equivalent to the login container
kubectl exec -it <pod-name> -c <container-name> bash
6.Pod expansion and contraction capacity
7.Pod Roll-up upgrade
Source: https://www.cnblogs.com/Cherry-Linux/p/7866427.html
Summary of Common KUBECTL commands