Free CKA Exam Braindumps

Create a Pod with main container busybox and which executes this "while true; do echo `Hi I am from Main container' >> /var/log/index.html; sleep 5; done" and with sidecar container with nginx image which exposes on port 80. Use emptyDir Volume and mount this volume on path /var/log for busybox and on path /usr/share/nginx/html for nginx container. Verify both containers are running.

  1. Solution:

    // create an initial yaml file with this
    kubectl run multi-cont-pod --image=busbox --restart=Never -- dry-run -o yaml > multi-container.yaml
    // edit the yml as below and create it
    kubectl create -f multi-container.yaml
    vim multi-container.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    labels:
    run: multi-cont-pod
    name: multi-cont-pod
    spec:
    volumes:
    - name: var-logs
    emptyDir: {}
    containers:
    - image: busybox
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo 'Hi I am from Main container' >> /var/log/index.html; sleep 5;done"]
    name: main-container
    volumeMounts:
    - name: var-logs
    mountPath: /var/log
    - image: nginx
    name: sidecar-container
    ports:
    - containerPort: 80
    volumeMounts:
    - name: var-logs


    mountPath: /usr/share/nginx/html
    restartPolicy: Never
    // Create Pod
    kubectl apply -f multi-container.yaml
    //Verify
    kubectl get pods

Answer(s): A



Exec into both containers and verify that main.txt exist and

  1. Solution:
    NEED TO WRITE ANSWER FOR THIS

Answer(s): A



Create an nginx pod and set an env value as 'var1=val1'. Check the env value existence within the pod

  1. Solution:

    kubectl run nginx --image=nginx --restart=Never --env=var1=val1 # then
    kubectl exec -it nginx -- env
    # or
    kubectl exec -it nginx -- sh -c 'echo $var1'
    # or
    kubectl describe po nginx | grep val1
    # or
    kubectl run nginx --restart=Never --image=nginx --env=var1=val1 -it --rm ­ env

Answer(s): A



Create a pod with init container which create a file "test.txt" in "workdir" directory. Main container should check a file "test.txt" exists and execute sleep 9999 if the file exists.

  1. Solution:

    // create an initial yaml file with this
    kubectl run init-cont-pod --image=alpine --restart=Never --dry-run -o


    yaml > init-cont-pod.yaml
    // edit the yml as below and create it
    vim init-cont-pod.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: init-cont-pod
    labels:
    app: myapp
    spec:
    volumes:
    - name: test-volume
    emptyDir: {}
    containers:
    - name: main-container
    image: busybox:1.28
    command: ['sh', '-c', 'if [ -f /workdir/test.txt ]; then sleep 9999; fi']
    volumeMounts:
    - name: test-volume
    mountPath: /workdir
    initContainers:
    - name: init-myservice
    image: busybox:1.28
    command: ['sh', '-c', "mkdir /workdir; echo >
    /workdir/test.txt"]
    volumeMounts:
    - name: test-volume
    mountPath: /workdir
    // Create the pod
    kubectl apply -f init-cont-pod.yaml
    kubectl get pods
    // Check Events by doing
    kubectl describe po init-cont-pod
    Init Containers:
    init-myservice:
    Container ID:
    docker://ebdbf5fad1c95111d9b0e0e2e743c2e347c81b8d4eb5abcccdfe1dd74524 0d4f
    Image: busybox:1.28
    Image ID: dockerpullable://busybox@sha256:141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df 416dea4f41046e0f37d47
    Port: <none>
    Host Port: <none>
    Command:
    sh
    -c
    mkdir /workdir; echo > /workdir/test.txt


    State: Terminated
    Reason: Completed

Answer(s): A






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

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