kubectl get svc, po kubectl get deploy, no kubectl get all kubectl get all --all-namespaces
Viewing and finding resources
Multiple resources
storage class
Resource name: storageclasses, Abbreviation: sc
kubectl get sc kubectl get sc -o yaml
Persistent volume declaration
Resource name: persistentvolumeclaims, abbreviation: pvc
kubectl get pvc kubectl describe pvc
Persistent Volumes
Resource name: persistentvolumes, abbreviation: pv
kubectl get pv kubectl describe pv
Ingresses
Resource name: ingresses, abbreviation: ing
kubectl get ing kubectl get ing --all-namespaces
Config maps
Resource name: configmaps, abbreviation: cm
kubectl get cm kubectl get cm --all-namespaces kubectl get cm --all-namespaces -o yaml
Secrets
kubectl get secrets kubectl get secrets --all-namespaces kubectl get secrets -o yaml
Roles
kubectl get roles --all-namespaces kubectl get roles --all-namespaces -o yaml
Replica Sets
kubectl get rs kubectl describe rs kubectl get rs -o wide kubectl get rs -o yaml
Resource name: replicasets, abbreviation: rs
Service Accounts
kubectl get sa kubectl get sa -o yaml kubectl get serviceaccounts default -o yaml >./sa.yaml kubectl replace serviceaccount default -f ./sa.yaml
Resource name: serviceaccounts, abbreviation: ev
Logs
kubectl logs [pod_name] kubectl logs --since=1h [pod_name] kubectl logs --tail=20 [pod_name] kubectl logs -f -c [container_name] [pod_name] kubectl logs [pod_name] > pod.log
Events
kubectl get events kubectl get events -n kube-system kubectl get events -w
Resource name: events, abbreviation: ev
Daemon Sets
kubectl get ds kubectl describe ds --all-namespaces kubectl describe ds [daemonset_name] -n [namespace_name] kubectl get ds [ds_name] -n [ns_name] -o yaml
Resource name: daemonsets, abbreviation: ds
Services
kubectl get svc kubectl describe svc kubectl get svc -o wide kubectl get svc -o yaml kubectl get svc --show-labels
Resource name: services, abbreviation: svc
Deployments
kubectl get deploy kubectl describe deploy kubectl get deploy -o wide kubectl get deploy -o yaml
Resource name: deployments, abbreviation: deploy
Namespaces
kubectl get ns kubectl get ns -o yaml kubectl describe ns
Resource name: namespaces, abbreviation: ns
Pods
kubectl get po # Display all container group information kubectl get po -o wide kubectl describe po kubectl get po --show-labels # View the labels of the container group kubectl get po -l app=nginx kubectl get po -o yaml kubectl get pod [pod_name] -o yaml --export kubectl get pod [pod_name] -o yaml --export > nameoffile.yaml # Export container group information to yaml file in yaml format kubectl get pods --field-selector status.phase=Running # Use the field selector to filter out container group information
Resource name: pods, abbreviation: po
Nodes
kubectl get no # Display all node information kubectl get no -o wide # Show more information about all nodes kubectl describe no # Display node details kubectl get no -o yaml # Display node details in yaml format kubectl get node --selector=[label_name] # Filter the node with the specified label kubectl get nodes -o jsonpath='{.items[\*].status.addresses[?(@.type="ExternalIP")].address}' # Output the field information defined by the jsonpath expression kubectl top node [node_name] # Display node (CPU/memory/storage) usage
Resource name: nodes, abbreviation: no
Comments