Free CKA Exam Braindumps (page: 12)

Page 12 of 31

Annotate the pod with name=webapp

  1. Solution:

    kubectl annotate pod nginx-dev-pod name=webapp
    kubectl annotate pod nginx-prod-pod name=webapp
    // Verify
    kubectl describe po nginx-dev-pod | grep -i annotations kubectl describe po nginx-prod-pod | grep -i annotations

Answer(s): A



Create a deployment called webapp with image nginx having 5 replicas in it, put the file in /tmp directory with named webapp.yaml

  1. Solution:

    //Create a file using dry run command
    kubectl create deploy --image=nginx --dry-run -o yaml > /tmp/webapp.yaml
    // Now, edit file webapp.yaml and update replicas=5
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    labels:
    app: webapp
    name: webapp
    spec:
    replicas: 5
    selector:
    matchLabels:
    app: webapp
    template:
    metadata:
    labels:
    app: webapp
    spec:
    containers:
    - image: nginx
    name: nginx
    Note: Search "deployment" in kubernetes.io site , you will get the page
    https://kubernetes.io/docs/concepts/workloads/controllers/deplo


    yment/
    // Verify the Deployment
    kubectl get deploy webapp --show-labels
    // Output the YAML file of the deployment webapp
    kubectl get deploy webapp -o yaml

Answer(s): A



Get the list of pods of webapp deployment

  1. Solution:

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

Answer(s): A



Scale the deployment from 5 replicas to 20 replicas and verify

  1. Solution:

    kubectl scale deploy webapp --replicas=20
    kubectl get deploy webapp
    kubectl get po -l app=webapp

Answer(s): A



Page 12 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