Ultimate Guide to Prepare CKA Certification Exam for Kubernetes Administrator in 2021 [Q36-Q61]

Share

Ultimate Guide to Prepare CKA Certification Exam for Kubernetes Administrator in 2021

Use Real CKA Dumps - Linux Foundation Correct Answers updated on 2021

NEW QUESTION 36
Get the pods with labels env=dev and env=prod and output the labels as well

Answer:

Explanation:
kubectl get pods -l 'env in (dev,prod)' --show-labels

 

NEW QUESTION 37
Set the node namedek8s-node-1asunavailable and reschedule all thepods running on it.

Answer:

Explanation:
See the solution below.
Explanation
solution

 

NEW QUESTION 38
Create a pod with environment variables as var1=value1.Check the environment variable in pod

  • A. kubectl run nginx --image=nginx --restart=Never --env=var1=value1
    # then
    kubectl exec -it nginx -- env
    # or
    kubectl exec -it nginx -- sh -c 'echo $var1'
    # or
    kubectl describe po nginx | grep value1
  • B. kubectl run nginx --image=nginx --restart=Never --env=var1=value1
    # then
    kubectl exec -it nginx -- env
    # or
    kubectl describe po nginx | grep value1

Answer: A

 

NEW QUESTION 39
Scale the deployment webserver to

Answer:

Explanation:
See the solution below.
Explanation
solution

 

NEW QUESTION 40
Create a file:
/opt/KUCC00302/kucc00302.txt that lists all pods that implement service in namespace development.
The format of the file should be one pod name per line.

Answer:

Explanation:
See the solution below.
Explanation
solution


 

NEW QUESTION 41
Get the list of pods of webapp deployment

  • A. // Get the label of the deployment
    kubectl get deploy --show-labels
    kubectl get pods -l app=webapp
  • B. // Get the label of the deployment
    kubectl get deploy --show-labels
    // Get the pods with that label
    kubectl get pods -l app=webapp

Answer: B

 

NEW QUESTION 42
Get the pods with label env=dev and output the labels

Answer:

Explanation:
kubectl get pods -l env=dev --show-labels

 

NEW QUESTION 43
Create a file called "config.txt" with two values key1=value1
and key2=value2. Then create a configmap named "keyvalcfgmap" andread data from the file "config.txt" and verify that configmap is created correctly

  • A. cat >> config.txt << EOF
    key1=value1
    key2=value2
    EOF
    cat config.txt
    // Create configmap from "config.txt" file
    kubectl create cm keyvalcfgmap --from-file=config.txt
    //Verify
    kubectl get cm keyvalcfgmap -o yaml
  • B. cat >> config.txt << EOF
    key1=value1
    key2=value2
    EOF
    kubectl create cm keyvalcfgmap --from-file=config.txt
    //Verify
    kubectl get cm keyvalcfgmap -o yaml

Answer: A

 

NEW QUESTION 44
Create a Pod nginx and specify both CPU, memory requests and limits together and verify.

  • A. kubectl run nginx-request --image=nginx --restart=Always --dryrun -o yaml > nginx-request.yml
    // add the resources section and create
    apiVersion: v1
    kind: Pod
    metadata:
    labels:
    run: nginx
    name: nginx-request
    spec:
    containers:
    - image: nginx
    name: nginx
    resources:
    requests:
    memory: "100Mi"
    cpu: "0.5"
    limits:
    memory: "200Mi"
    cpu: "1"
    restartPolicy: Always
    k kubectl apply -f nginx-request.yaml
    // Verify
    Kubectl top po
  • B. kubectl run nginx-request --image=nginx --restart=Always --dryrun -o yaml > nginx-request.yml
    // add the resources section and create
    apiVersion: v1
    kind: Pod
    metadata:
    labels:
    run: nginx
    name: nginx
    resources:
    requests:
    memory: "100Mi"
    cpu: "0.4"
    limits:
    memory: "200Mi"
    cpu: "7"
    restartPolicy: Always
    k kubectl apply -f nginx-request.yaml
    // Verify
    Kubectl top po

Answer: A

 

NEW QUESTION 45
Get list of PVs and order by size and write to file "/opt/pvstorage.txt"

Answer:

Explanation:
kubectl get pv --sort-by=.spec.capacity.storage > /opt/pv storage.txt

 

NEW QUESTION 46
Add a taint to node "worker-2" with effect as "NoSchedule" and
list the node with taint effect as "NoSchedule"

  • A. // Add taint to node "worker-2"
    kubectl taint nodes worker-2 key=value:NoSchedule
    .items[*]}{.metadata.name} {.spec.taints[?(
    @.effect=='NoSchedule' )].effect}{\"\n\"}{end}" | awk 'NF==2
    {print $0}'
  • B. // Add taint to node "worker-2"
    kubectl taint nodes worker-2 key=value:NoSchedule
    // Verify
    // Using "custom-coloumns" , you can customize which coloumn to
    be printed
    kubectl get nodes -o customcolumns=NAME:.metadata.name,TAINTS:.spec.taints --no-headers
    // Using jsonpath
    kubectl get nodes -o jsonpath="{range
    .items[*]}{.metadata.name} {.spec.taints[?(
    @.effect=='NoSchedule' )].effect}{\"\n\"}{end}" | awk 'NF==2
    {print $0}'

Answer: B

 

NEW QUESTION 47
Check the history of deployment

Answer:

Explanation:
kubectl rollout history deployment webapp

 

NEW QUESTION 48
List all the pods sorted by created timestamp

Answer:

Explanation:
kubect1 get pods--sort-by=.metadata.creationTimestamp

 

NEW QUESTION 49
Create a pod as follows:
* Name: mongo
* Using Image: mongo
* In a new Kubernetes namespace named

Answer:

Explanation:
See the solution below.
Explanation
solution

 

NEW QUESTION 50
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.

Answer:

Explanation:
See the solution below.
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

 

NEW QUESTION 51
To protect your firewall and network from single source denial of service (DoS) attacks that can overwhelm its packet buffer and cause legitimate traffic to drop, you can configure:

  • A. PBP (Packet Buffer Protection)
  • B. PBP (Protocol Based Protection)
  • C. BGP (Border Gateway Protocol)
  • D. PGP (Packet Gateway Protocol)

Answer: B

 

NEW QUESTION 52
Undo the deployment to the previous version 1.17.1 and verify Image has the previous version

Answer:

Explanation:
kubectl rollout undo deploy webapp kubectl describe deploy webapp | grep Image

 

NEW QUESTION 53
For this item, you will have to ssh and complete all tasks on these
nodes. Ensure that you return to the base node (hostname: ) when you have completed this item.
Context
As an administrator of a small development team, you have been asked to set up a Kubernetes cluster to test the viability of a new application.
Task
You must use kubeadm to perform this task. Any kubeadm invocations will require the use of the
--ignore-preflight-errors=all option.
Configure the node ik8s-master-O as a master node. .
Join the node ik8s-node-o to the cluster.

Answer:

Explanation:
See the solution below.
Explanation
solution
You must use the kubeadm configuration file located at /etc/kubeadm.conf when initializingyour cluster.
You may use any CNI plugin to complete this task, but if you don't have your favourite CNI plugin's manifest URL at hand, Calico is one popular option:
https://docs.projectcalico.org/v3.14/manifests/calico.yaml
Docker is already installed on both nodes and apt has been configured so that you can install the required tools.

 

NEW QUESTION 54
Undo the deployment with the previous version and verify
everything is Ok

Answer:

Explanation:
kubectl rollout undo deploy webapp kubectl rollout status deploy webapp kubectl get pods

 

NEW QUESTION 55
Create a daemonset named "Prometheus-monitoring" using image=prom/Prometheus which runs in all the nodes in the cluster. Verify the pod running in all the nodes

  • A. vim promo-ds.yaml
    apiVersion: apps/v1
    kind: DaemonSet
    metadata:
    name: prometheus-monitoring
    spec:
    selector:
    matchLabels:
    name: prometheus
    template:
    metadata:
    labels:
    name: prometheus
    spec:
    tolerations:
    # remove it if your masters can't run pods
    - key: node-role.kubernetes.io/master
    effect: NoSchedule
    containers:
    - name: prometheus-container
    image: prom/prometheus
    volumeMounts:
    - name: varlog
    mountPath: /var/log
    - name: varlibdockercontainers
    mountPath: /var/lib/docker/containers
    readOnly: true
    volumes:
    - name: varlog
    emptyDir: {}
    - name: varlibdockercontainers
    emptyDir: {}
    kubectl apply -f promo-ds.yaml
    NOTE: Deamonset will get scheduled to "default" namespace, to
    schedule deamonset in specific namespace, then add
    "namespace" field in metadata
    //Verify
    kubectl get ds
    NAME DESIRED CURRENT READY UP-TO-DATE
    AVAILABLE NODE SELECTOR AGE
    prometheus-monitoring 6 6 0 6
    0 <none> 7s
    kubectl get no # To get list of nodes in the cluster
    // There are 6 nodes in the cluster, so a pod gets scheduled to
    each node in the cluster
  • B. vim promo-ds.yaml
    apiVersion: apps/v1
    kind: DaemonSet
    metadata:
    name: prometheus-monitoring
    spec:
    selector:
    matchLabels:
    name: prometheus
    template:
    metadata:
    labels:
    name: prometheus
    spec:
    tolerations:
    # remove it if your masters can't run pods
    - key: node-role.kubernetes.io/master
    effect: NoSchedule
    containers:
    - name: prometheus-container
    - name: varlibdockercontainers
    mountPath: /var/lib/docker/containers
    readOnly: true
    volumes:
    - name: varlog
    emptyDir: {}
    - name: varlibdockercontainers
    emptyDir: {}
    kubectl apply -f promo-ds.yaml
    NOTE: Deamonset will get scheduled to "default" namespace, to
    schedule deamonset in specific namespace, then add
    "namespace" field in metadata
    //Verify
    kubectl get ds
    NAME DESIRED CURRENT READY UP-TO-DATE
    AVAILABLE NODE SELECTOR AGE
    prometheus-monitoring 8 8 0 6
    0 <none> 7s
    kubectl get no # To get list of nodes in the cluster
    // There are 6 nodes in the cluster, so a pod gets scheduled to
    each node in the cluster

Answer: A

 

NEW QUESTION 56
Get list of all the nodes with labels

Answer:

Explanation:
kubectl get nodes --show-labels

 

NEW QUESTION 57
For this item, you will havetosshto the nodesik8s-master-0andik8s-node-0and complete all tasks on thesenodes. Ensure that you return tothe base node (hostname:node-1) when you havecompleted this item.
Context
As an administrator of a smalldevelopment team, you have beenasked to set up a Kubernetes clusterto test the viability of a newapplication.
Task
You must usekubeadmto performthis task. Anykubeadminvocationswill require the use of the
--ignore-preflight-errors=alloption.
* Configure thenodeik8s-master-Oas a masternode. .
* Join the nodeik8s-node-otothe cluster.

Answer:

Explanation:
See the solution below.
Explanation
solution
You must use thekubeadmconfiguration file located at when initializingyour cluster.
You may use any CNI pluginto complete this task, but ifyou don't have your favouriteCNI plugin's manifest URL athand, Calico is one popularoption:https://docs.projectcalico.org/v3.14/manifests/calico.yaml Docker is already installedon both nodes and hasbeen configured so that you caninstall the required tools.

 

NEW QUESTION 58
List all the events sorted by timestamp and put them into file.log and verify

  • A. kubectl get events --sort-by=.metadata.creationTimestamp
    kubectl get events --sort-by=.metadata.creationTimestamp >
    test-file.log
    cat test-file.log
  • B. kubectl get events --sort-by=.metadata.creationTimestamp
    // putting them into file.log
    kubectl get events --sort-by=.metadata.creationTimestamp >
    cat test-file.log
  • C. kubectl get events --sort-by=.metadata.creationTimestamp
    // putting them into file.log
    kubectl get events --sort-by=.metadata.creationTimestamp >
    test-file.log
    cat test-file.log

Answer: C

 

NEW QUESTION 59
Create a PersistentVolumeClaim of at least 3Gi storage and access mode ReadWriteOnce and verify status is Bound

  • A. vim task-pv-claim.yaml
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
    name: task-pv-claim
    spec:
    storageClassName: ""
    accessModes:
    - ReadWriteOnce
    resources:
    requests:
    storage: 3Gi
    kubectl apply -f task-pv-claim.yaml
    //Verify
    kubectl get pv
    NAME CAPACITY ACCESS
    MODES RECLAIM POLICY STATUS CLAIM
    STORAGECLASS REASON AGE
    task-pv-volume 5Gi RWO
    Retain Bound default/task-pv-claim
    6m16s
    kubectl get pvc
    NAME STATUS VOLUME
    CAPACITY ACCESS MODES STORAGECLASS AGE
    task-pv-claim Bound task-pv-volume
    5Gi RWO 6s
  • B. vim task-pv-claim.yaml
    apiVersion: v2
    kind: PersistentVolumeClaim
    metadata:
    name: task-pv-claim
    spec:
    storageClassName: ""
    accessModes:
    - ReadWriteOnce
    resources:
    requests:
    storage: 4Gi
    kubectl apply -f task-pv-claim.yaml
    //Verify
    kubectl get pv
    NAME CAPACITY ACCESS
    MODES RECLAIM POLICY STATUS CLAIM
    STORAGECLASS REASON AGE
    task-pv-volume 4Gi RWO
    Retain Bound default/task-pv-claim
    6m16s
    kubectl get pvc
    NAME STATUS VOLUME
    CAPACITY ACCESS MODES STORAGECLASS AGE
    task-pv-claim Bound task-pv-volume
    5Gi RWO 6s

Answer: A

 

NEW QUESTION 60
Score: 4%

Task
Check to see how many nodes are ready (not including nodes tainted NoSchedule ) and write the number to
/opt/KUSC00402/kusc00402.txt

Answer:

Explanation:
See the solution below.
Explanation
Solution:
kubectl describe nodes | grep ready|wc -l
kubectl describe nodes | grep -i taint | grep -i noschedule |wc -l
echo 3 > /opt/KUSC00402/kusc00402.txt
#
kubectl get node | grep -i ready |wc -l
# taintsnoSchedule
kubectl describe nodes | grep -i taints | grep -i noschedule |wc -l
#
echo 2 > /opt/KUSC00402/kusc00402.txt

 

NEW QUESTION 61
......

Kubernetes Administrator -CKA Exam-Practice-Dumps: https://www.dumpstests.com/CKA-latest-test-dumps.html

CKA Premium Files Test pdf - Free Dumps Collection: https://drive.google.com/open?id=1GQCNPRdbm4XYgo4J2OAXzYyFCX2f8_cG