Kubectl Flashcards

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

What is kubectl?

A

Command line tool from kubernetes for communicating with a kubernete cluster

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

Get name of your nodes

A

kubectl get nodes
kubectl get nodes –show-labels

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

Check kubectl version

A

kubectl version

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

Check the location and creds kubectl knows about

A

kubectl config view

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

Choose one of your nodes and add a label to it

A

kubectl label nodes <node-name> disktype=ssd</node-name>

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

Verify pod is running on chosen name

A

kubectl get pods –output=wide

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

List all pods in given namespace

A

kubectl get pods –namespace <org’s namespace>

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

Get details on specific pod

A

kubectl describe pod <pod> --namespace <namespace-name></namespace-name></pod>

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

Exec into container

A

kubectl exec –stdin –tty <podname> --/bin/bash</podname>

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

Quit shell in container

A

?

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

Flow to exec into container

A

1- auth to aws
2- kubectl get nodes
3- kubectl get pods –namespace <namespace-name>
4-kubectl describe pod <pod-name> --namespace <namespace-name>
5-kubectl exec --stdin -tty <podname> --namespace <namespace-name> --/bin/bash</namespace-name></podname></namespace-name></pod-name></namespace-name>

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

Print logs for pod

A

kubectl logs <pod-name></pod-name>

kubectl logs –since=6h -c <what/sthis?> <podname> --namespace <namespace-name></namespace-name></podname>

kubectl logs pod-name –since=2h

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

Show streaming logs

A

kubectl logs pod-name container-name -f

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

Get most recent 50 lines of logs for a pod

A

kubectl logs –tail=50<pod_name></pod_name>

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

Print the logs for a container in a pod

A

kubectl logs -c <container> <pod></pod></container>

17
Q

Output logs for a pod int a file named ‘pod.log’

A

kubectl logs <pod_name> pod.log</pod_name>

18
Q

View logs for a previously failed pod

A

kubectl logs –previous <pod-name></pod-name>

19
Q

In an ordinary terminal window, list the environment variables in the running container

A

kubectl exec shell-demo env

20
Q

Open a shell when a pod has more than one container

A

kubectl exec -I -t <my-pod> --container main-app --/bin/bash</my-pod>

21
Q

See which cluster currently connected to

A

kubectl config current-context

22
Q

Find your pods

A

kubectl get pods -n <namespace></namespace>

23
Q

Change which cluster connected to

A

kubectl config use-context <cluster></cluster>