For Pods and Container Introspection

CommandFunction
kubectl get podsLists all current pods
kubectl describe pod<name>Describes pod names
kubectl get rcLists 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 svcLists services
kubectl describe svc<name>Shows a service name
kubectl delete pod<name>Deletes a pod
kubectl get nodes -wWatches nodes continuously

For Debugging

FunctionCommand
To execute the command on service by selecting a containerkubectl exec<service><commands>[-c< $container>]
To get logs from the service for a containerkubectl logs -f<name>>[-c< $container>]
To watch kubelet logswatch -n 2 cat/var/log/kublet.log
To show metrics for a nodekubectl top node
To show metrics for a podkubectl top pod

For Cluster Introspection

FunctionCommand
To get version-related informationkubectl version
To get cluster-related informationkubectl cluster-info
To get configuration detailskubectl config g view
To get information about a nodekubectl describe node<node>

Objects

Some of the common objects used in Kubernetes are mentioned in the below table:

Allclusterrolebindingsclusterroles
cm= conf gmapscontrollerrevisionscrd=custom resource definition
Cronjobscs=component statusescsr= certificate signing requests
Deploy=deploymentsds= daemon setsep=end points
ev= eventshpa= horizontal pod autoscalinging= ingress
jobslimits=limit rangesNetpol- network policies
No = nodesns= namespacespdb= pod distribution budgets
po= podsPod presetPod templates
Psp= pod security policiesPv= persistent volumespvc= persistent volume claims
quota= resource quotasrc= replication controllersRole bindings
rolesrs= replica setssa= service accounts
sc= storage classessecretssts= stateful sets

Other Quick Commands

Additionally, we do have some quick commands that are often very useful:

FunctionCommand
To launch a pod with a name and an imagekubectl 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 instanceskubectl scale –replicas=<count>rc<name>
To map the external port to the internal replication portexpose 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 namespacekubectl create namespace <namespace>
To allow the master node to run podskubectltaintnodes –all-node-role.kuernetes.io/master-

Advertisement