Free CKA Exam Braindumps (page: 4)

Page 4 of 31

Create a pod that having 3 containers in it? (Multi-Container)

  1. Solution:

    image=nginx, image=redis, image=consul
    Name nginx container as "nginx-container"
    Name redis container as "redis-container"
    Name consul container as "consul-container"
    Create a pod manifest file for a container and append container section for rest of the images
    kubectl run multi-container --generator=run-pod/v1 --image=nginx -- dry-run -o yaml > multi-container.yaml
    # then
    vim multi-container.yaml
    apiVersion: v1
    kind: Pod
    metadata:


    labels:
    run: multi-container
    name: multi-container
    spec:
    containers:
    - image: nginx
    name: nginx-container
    - image: redis
    name: redis-container
    - image: consul
    name: consul-container
    restartPolicy: Always

Answer(s): A



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.

  1. Solution:

    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

Answer(s): A



Get IP address of the pod ­ "nginx-dev"

  1. Solution:

    Kubect1 get po -o wide
    Using JsonPath
    kubect1 get pods -o=jsonpath='{range
    .items[*]}{.metadata.name}{"\t"}{.status.podIP}{"\n"}{end}'

Answer(s): A



Print pod name and start time to "/opt/pod-status" file

  1. Solution:
    kubect1 get pods -o=jsonpath='{range
    .items[*]}{.metadata.name}{"\t"}{.status.podIP}{"\n"}{end}'

Answer(s): A



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