kubectl - Pod Design Flashcards

1
Q

list pods labels in my-namespace

A

kubectl get po –show-labels -n my-namespace

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

Create nginx-prod1 pod with label env=prod

A

kubectl run nginx-prod1 –image=nginx –restart=Never –labels=env=dev

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

show pods with label env=dev

A

kubectl get po -l env=dev

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

show pods that have label env

A

kubectl get po -L env

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

create nginx pod on node-1

A
  1. kubectl run nginx –image=nginx –restart=Never –dry-run=client -o yaml > nginx-pod.yaml
  2. Add yaml:
    spec:
    nodeName: node-1
  3. kubectl create -f nginx-pod.yaml
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Create a service for nginx on port 80 targeting port 9376

A

kubectl expose deployment nginx –port=80 –targetPort=9376

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

Create deployment named hr-app running nginx:1.18 with 2 replicas

A
  1. kubectl create deployment hr-app –image=nginx:1.18 –dry-run=client -o yaml > deploy.yaml
  2. vim deploy.yaml ->
    spec:
    replicas: 2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Scale hr-app to 3 replicas

A

kubectl scale deployment/hr-app –replicas 3

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

Remove a NoSchedule taint from node1 with selector spray=mortein

A

kubectl taint nodes node1 spray=mortein:NoSchedule-

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

Label node1 node with color=blue

A

kubectl label node node1 color=blue

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

Clean cluster by removing autoscaled deployment webapp

A

kubectl delete deployment webapp

kubectl delete hpa webapp

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

create cronjob date-job that uses busybox image a prints date and “hello” every minute

A

kubectl create cronjob date-job –image=busybox –schedule=”*/1 * * * *” – bin/sh -c “date; echo hello”

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