Quick Fire Kube Commands Flashcards

1
Q

How do you get a list of nodes in a Kubernetes cluster?

A

kubectl get nodes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How would you create a simple deployment using the image “busybox”?

A

kubectl create deployment <name> --image=busybox</name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How would you find out which pods are deployed in your cluster?

A

kubectl get pods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can you execute a command inside a pod?

A

kubectl exec <pod-name> -- <command></command></pod-name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How would you expose a service using a load balancer?

A

kubectl expose deployment <deployment> --type=LoadBalancer</deployment>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How would you scale a deployment to two replicas?

A

kubectl scale deployment <deployment> --replicas=2</deployment>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How would you use the output of an existing deployment to get a good YAML template for another one?

A

kubectl describe deployment <deployment> -o yaml > file.yaml</deployment>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How would you create a deployment from a file?

A

kubectl create -f <filename></filename>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How would you update an existing deployment from a file?

A

kubectl replace -f <filename></filename>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How would you expose port 80 on an nginx container?

A

Configure a shared port and protocol in the image definition, redeploy, and run kubectl expose deployment/<deployment></deployment>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you create a service from a deployment?

A

kubectl expose deployment/<deployment></deployment>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you get the endpoint for a service?

A

kubectl get ep <service></service>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How would you scale a deployment to a number of replicas?

A

kubectl scale deployment <deployment> --replicas=x</deployment>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you make a node available to a scheduler again?

A

kubectl uncordon <node></node>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What can you add to a command to make it work across all namespaces?

A

–all-namespaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How would you see the overall configuration of your cluster?

A

kubectl config view

17
Q

What command would you use to create an api token?

A

kubectl create token default

18
Q

How would you create a Kube API proxy?

A

kubectl proxy –api-prefix=/

19
Q

How do you get the details of a particular replicaset?

A

kubectl describe rs <replicaset></replicaset>

20
Q

How would you delete a replicaset, but leave its pods running?

A

kubectl delete rs <replicaset> --cascade=orphan</replicaset>

21
Q

How would you see the pods labelled “system”?

A

kubectl get pods -L system

22
Q

How would you delete all pods with the system label “IsolatedPod”?

A

kubectl delete pod -l system=IsolatedPod

23
Q

How would you revert a change to a deployment?

A

kubectl rollback undo deploy <deployment></deployment>

24
Q
A