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