Kubectl common command, welcome to add other common command

Kubectl syntax overview

$ kubectl [command] [TYPE] [NAME] [flags]

1 command subcommand used to operate Kubernetes cluster resource object commands, such as create, delete, describe, get, apply, etc

2 type Type of the resource object. There are the following Pod, ReplicaSet, ReplicationController, Deployment, StatefulSet, DaemonSet, Job, CronJob, HorizontalPodAutoscaling, Node, Namespac E, Service, Ingress, Label, CustomResourceDefinition

3 Name Name of the resource object. The value is case sensitive. If you do not specify a name, the system returns a list of all objects belonging to TYPE. For example, $kubectl get Pods returns a list of all pods (my-pod in this blog).

4 Flags kubectl -o yaml displays the result in YAML format

Kubectl get series of commands

1 kubectl get services lists all services in the current namespace

2 kubectl get Pods Lists all pods in the current namespace

3 kubectl get Pods -o wide Lists all pods in the current namespace with more detailed information, including age, IP,node, etc

4 kubectl get pod my-pod -o yaml get pod configuration file in YAML format (json format is also available)

Kubectl describe series of commands

1 kubectl describe Nodes my-node Displays node details

2 Kubectl describe Pods my-pod Displays pod details

Kubectl logs series commands

1 kubectl logs my-pod

Kubectl logs -f my-pod stream

Kubectl exec series of commands

Kubectl exec-it my-pod bash kubectl exec-it my-pod bash

2 kubectl exec my-pod env