nerdexam
Linux_Foundation

CKAD · Question #16

Given a container that writes a log file in format A and a container that converts log files from format A to format B, create a deployment that runs both containers such that the log files from the…

The task requires creating a Kubernetes Deployment with two containers, sharing an emptyDir volume, and mounting a ConfigMap to the sidecar, demonstrating proficiency in multi-container pod design and kubectl YAML management.

Submitted by certguy· May 4, 2026Application Environment, Configuration and Security

Question

Given a container that writes a log file in format A and a container that converts log files from format A to format B, create a deployment that runs both containers such that the log files from the first container are converted by the second container, emitting logs in format B. Task: • Create a deployment named deployment-xyz in the default namespace, that: • Includes a primary lfccncf/busybox:1 container, named logger-dev • Includes a sidecar lfccncf/fluentd:v0.12 container, named adapter-zen • Mounts a shared volume /tmp/log on both containers, which does not persist when the pod is deleted • Instructs the logger-dev container to run the command
while true; do
 echo "i luv cncf" >> /tmp/log/input.log;
 sleep 10;
done
which should output logs to /tmp/log/input.log in plain text format, with example values:
i luv cncf
i luv cncf
i luv cncf
• The adapter-zen sidecar container should read /tmp/log/input.log and output the data to /tmp/log/output.* in Fluentd JSON format. Note that no knowledge of Fluentd is required to complete this task: all you will need to create this is to create the ConfigMap from the spec file provided at /opt/KDMC00102/fluentd-configma p.yaml , and mount that ConfigMap to /fluentd/etc in the adapter-zen sidecar container

Exhibits

CKAD question #16 exhibit 1
CKAD question #16 exhibit 2
CKAD question #16 exhibit 3
CKAD question #16 exhibit 4
CKAD question #16 exhibit 5
CKAD question #16 exhibit 6

Explanation

The task requires creating a Kubernetes Deployment with two containers, sharing an emptyDir volume, and mounting a ConfigMap to the sidecar, demonstrating proficiency in multi-container pod design and kubectl YAML management.

Approach. To correctly complete the task, the user must perform the following interactions in the terminal:

  1. Create the ConfigMap: The task specifies that the ConfigMap for Fluentd is provided at /opt/KDMC00102/fluentd-configmap.yaml. This ConfigMap must be created first so the Deployment can reference it.

    kubectl create -f /opt/KDMC00102/fluentd-configmap.yaml
    

    Reasoning: The adapter-zen sidecar container needs this ConfigMap mounted to /fluentd/etc. The Deployment will fail to create the Pod if the referenced ConfigMap does not exist.

  2. Create/Edit Deployment YAML: The core of the task is to define a Kubernetes Deployment. The user should create a new YAML file (e.g., deployment-xyz.yaml) with the following content (or generate a basic deployment and modify it using vim):

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: deployment-xyz
      labels:
        app: logger-adapter # Label for selector
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: logger-adapter
      template:
        metadata:
          labels:
            app: logger-adapter
        spec:
          # Define volumes for the pod
          volumes:
          - name: log-volume
            emptyDir:
              medium: Memory # Use tmpfs for non-persistent, in-memory storage
          - name: fluentd-config
            configMap:
              name: fluentd-configmap # Assuming the ConfigMap file defines this name
          # Define containers for the pod
          containers:
          - name: logger-dev
            image: lfccncf/busybox:1
            command: ["sh", "-c"]
            args: # Use args for multi-word commands
            - while true; do echo "i luv cncf" >> /tmp/log/input.log; sleep 10; done
            volumeMounts:
            - name: log-volume
              mountPath: /tmp/log # Mount shared log volume
          - name: adapter-zen
            image: lfccncf/fluentd:v0.12
            volumeMounts:
            - name: log-volume
              mountPath: /tmp/log # Mount shared log volume
            - name: fluentd-config
              mountPath: /fluentd/etc # Mount ConfigMap for Fluentd config
    

    Reasoning: This YAML file correctly defines a Deployment named deployment-xyz with one replica, containing a pod with two specified containers (logger-dev and adapter-zen). It configures an emptyDir volume for shared logging and a configMap volume to inject Fluentd configuration, as required by the task. The command and args are specified correctly for the logger-dev container.

  3. Apply the Deployment: Once the deployment-xyz.yaml file is created and saved, apply it to the Kubernetes cluster.

    kubectl apply -f deployment-xyz.yaml
    

    Reasoning: This command creates or updates the Deployment resource based on the provided YAML, which will then manage the creation of the Pod with the two containers.

Common mistakes.

  • common_mistake. A common mistake would be to create a standalone Pod resource instead of a Deployment. The question explicitly asks for a 'deployment named deployment-xyz'. Creating a Pod directly would fulfill the immediate container requirements but would lack the self-healing, scaling, and update capabilities that a Deployment provides. Another mistake, hinted at by the exhibit, is incorrect YAML syntax or structure, such as misplacing mountPath (it should be nested under volumeMounts within a container definition) or incorrect indentation. Forgetting to create the ConfigMap before the Deployment, or misspelling its name in the Deployment YAML, would also lead to an error. Incorrectly defining the emptyDir volume or failing to mount it to both containers, or omitting the ConfigMap mount for the adapter-zen sidecar, would result in the log conversion not functioning as intended. Misconfiguring the command and args for the logger-dev container would prevent it from writing logs.

Concept tested. This question primarily tests the understanding and application of Kubernetes Deployments, multi-container Pod design (sidecar pattern), shared volumes (emptyDir), ConfigMaps for configuration injection, and kubectl CLI proficiency for resource creation and YAML manipulation.

Topics

#Sidecar pattern#EmptyDir volume#ConfigMap#Multi-container pod

Community Discussion

No community discussion yet for this question.

Full CKAD Practice