Quick Fire Kube Commands Flashcards
How do you get a list of nodes in a Kubernetes cluster?
kubectl get nodes
How would you create a simple deployment using the image “busybox”?
kubectl create deployment <name> --image=busybox</name>
How would you find out which pods are deployed in your cluster?
kubectl get pods
How can you execute a command inside a pod?
kubectl exec <pod-name> -- <command></command></pod-name>
How would you expose a service using a load balancer?
kubectl expose deployment <deployment> --type=LoadBalancer</deployment>
How would you scale a deployment to two replicas?
kubectl scale deployment <deployment> --replicas=2</deployment>
How would you use the output of an existing deployment to get a good YAML template for another one?
kubectl describe deployment <deployment> -o yaml > file.yaml</deployment>
How would you create a deployment from a file?
kubectl create -f <filename></filename>
How would you update an existing deployment from a file?
kubectl replace -f <filename></filename>
How would you expose port 80 on an nginx container?
Configure a shared port and protocol in the image definition, redeploy, and run kubectl expose deployment/<deployment></deployment>
How do you create a service from a deployment?
kubectl expose deployment/<deployment></deployment>
How do you get the endpoint for a service?
kubectl get ep <service></service>
How would you scale a deployment to a number of replicas?
kubectl scale deployment <deployment> --replicas=x</deployment>
How do you make a node available to a scheduler again?
kubectl uncordon <node></node>
What can you add to a command to make it work across all namespaces?
–all-namespaces
How would you see the overall configuration of your cluster?
kubectl config view
What command would you use to create an api token?
kubectl create token default
How would you create a Kube API proxy?
kubectl proxy –api-prefix=/
How do you get the details of a particular replicaset?
kubectl describe rs <replicaset></replicaset>
How would you delete a replicaset, but leave its pods running?
kubectl delete rs <replicaset> --cascade=orphan</replicaset>
How would you see the pods labelled “system”?
kubectl get pods -L system
How would you delete all pods with the system label “IsolatedPod”?
kubectl delete pod -l system=IsolatedPod
How would you revert a change to a deployment?
kubectl rollback undo deploy <deployment></deployment>