ExamGecko
Question list
Search
Search

List of questions

Search

Question 38 - CKA discussion

Report
Export

Create 2 nginx image pods in which one of them is labelled with env=prod and another one labelled with env=dev and verify the same.

A.
See the solution below.
Answers
A.
See the solution below.
Suggested answer: A

Explanation:

kubectl run --generator=run-pod/v1 --image=nginx -- labels=env=prod nginx-prod --dry-run -o yaml >

nginx-prodpod.yaml Now, edit nginx-prod-pod.yaml file and remove entries like "creationTimestamp:

null" "dnsPolicy: ClusterFirst"

vim nginx-prod-pod.yaml

apiVersion: v1

kind: Pod

metadata:

labels:

env: prod

name: nginx-prod

spec:

containers:

- image: nginx

name: nginx-prod

restartPolicy: Always

# kubectl create -f nginx-prod-pod.yaml

kubectl run --generator=run-pod/v1 --image=nginx --

labels=env=dev nginx-dev --dry-run -o yaml > nginx-dev-pod.yaml

apiVersion: v1

kind: Pod

metadata:

labels:

env: dev

name: nginx-dev

spec:

containers:

- image: nginx

name: nginx-dev

restartPolicy: Always

# kubectl create -f nginx-prod-dev.yaml

Verify :

kubectl get po --show-labels

kubectl get po -l env=prod

kubectl get po -l env=dev

asked 18/09/2024
HWANG SEON TAE
43 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first