For Pods and Container Introspection
Command | Function |
kubectl get pods | Lists all current pods |
kubectl describe pod<name> | Describes pod names |
kubectl get rc | Lists all replication controllers |
kubectl get rc –namespace=”namespace” | Lists replication controllers in a namespace |
kubectl describe rc <name> | Shows the replication controller name |
kubectl get svc | Lists services |
kubectl describe svc<name> | Shows a service name |
kubectl delete pod<name> | Deletes a pod |
kubectl get nodes -w | Watches nodes continuously |
For Debugging
Function | Command |
To execute the command on service by selecting a container | kubectl exec<service><commands>[-c< $container>] |
To get logs from the service for a container | kubectl logs -f<name>>[-c< $container>] |
To watch kubelet logs | watch -n 2 cat/var/log/kublet.log |
To show metrics for a node | kubectl top node |
To show metrics for a pod | kubectl top pod |
For Cluster Introspection
Function | Command |
To get version-related information | kubectl version |
To get cluster-related information | kubectl cluster-info |
To get configuration details | kubectl config g view |
To get information about a node | kubectl describe node<node> |
Objects
Some of the common objects used in Kubernetes are mentioned in the below table:
All | clusterrolebindings | clusterroles |
cm= conf gmaps | controllerrevisions | crd=custom resource definition |
Cronjobs | cs=component statuses | csr= certificate signing requests |
Deploy=deployments | ds= daemon sets | ep=end points |
ev= events | hpa= horizontal pod autoscaling | ing= ingress |
jobs | limits=limit ranges | Netpol- network policies |
No = nodes | ns= namespaces | pdb= pod distribution budgets |
po= pods | Pod preset | Pod templates |
Psp= pod security policies | Pv= persistent volumes | pvc= persistent volume claims |
quota= resource quotas | rc= replication controllers | Role bindings |
roles | rs= replica sets | sa= service accounts |
sc= storage classes | secrets | sts= stateful sets |
Other Quick Commands
Additionally, we do have some quick commands that are often very useful:
Function | Command |
To launch a pod with a name and an image | kubectl run<name> — image=<image-name> |
To create a service described in <manifest.yaml> | kubectl create -f <manifest.yaml> |
To scale the replication counter to count the number of instances | kubectl scale –replicas=<count>rc<name> |
To map the external port to the internal replication port | expose rc<name> –port=<external>–target-port=<internal> |
To stop all pods in <n> | kubectl drain<n>– delete-local-data–force–ignore-daemonset |
To create a namespace | kubectl create namespace <namespace> |
To allow the master node to run pods | kubectltaintnodes –all-node-role.kuernetes.io/master- |
Like this:
Like Loading...
Related