Free CKA Exam Braindumps (page: 11)

Page 11 of 31

Get all the pods with label "env"

  1. Solution:

    kubectl get pods -L env

Answer(s): A



Change the label for one of the pod to env=uat and list all the pods to verify

  1. Solution:


    kubectl label pod/nginx-dev3 env=uat --overwrite
    kubectl get pods --show-labels

Answer(s): A



Get list of all the nodes with labels

  1. Solution:

    kubectl get nodes --show-labels

Answer(s): A



Create a nginx pod that will be deployed to node with the label "gpu=true"

  1. Solution:

    kubectl run nginx --image=nginx --restart=Always --dry-run -o yaml > nodeselector-pod.yaml
    // add the nodeSelector like below and create the pod kubectl apply -f nodeselector-pod.yaml
    vim nodeselector-pod.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: nginx
    spec:
    nodeSelector:
    gpu: true
    containers:
    - image: nginx
    name: nginx
    restartPolicy: Always
    kubectl apply -f nodeselector-pod.yaml
    //Verify
    kubectl get no ­show-labels
    kubectl get po
    kubectl describe po nginx | grep Node-Selectors

Answer(s): A



Page 11 of 31



Post your Comments and Discuss Linux Foundation CKA exam with other Community members:

Atsushi commented on January 13, 2024
That's good!!
Anonymous
upvote