0
0
Kubernetesdevops~20 mins

Container logging architecture in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Container Logging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding container log storage locations

Where does Kubernetes typically store container logs on the node by default?

A/home/user/.kube/logs directory
B/etc/kubernetes/logs directory
C/usr/local/bin/logs directory
D/var/log/containers directory
Attempts:
2 left
💡 Hint

Think about where Docker or container runtimes write logs on the host.

💻 Command Output
intermediate
2:00remaining
Output of kubectl logs command

What is the output of the command kubectl logs my-pod if the pod has a container that writes 'Hello World' to stdout?

AError: pod not found
BNo logs found for container
CHello World
Dkubectl: command not found
Attempts:
2 left
💡 Hint

This command shows the container's standard output logs.

Configuration
advanced
3:00remaining
Configuring a Fluentd DaemonSet for cluster-wide logging

Which configuration snippet correctly deploys Fluentd as a DaemonSet to collect logs from all nodes?

A
apiVersion: apps/v1
kind: Deployment
metadata:
  name: fluentd
spec:
  replicas: 3
  selector:
    matchLabels:
      name: fluentd
  template:
    metadata:
      labels:
        name: fluentd
    spec:
      containers:
      - name: fluentd
        image: fluent/fluentd
        volumeMounts:
        - name: varlog
          mountPath: /var/log
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
B
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd
spec:
  selector:
    matchLabels:
      name: fluentd
  template:
    metadata:
      labels:
        name: fluentd
    spec:
      containers:
      - name: fluentd
        image: fluent/fluentd
        volumeMounts:
        - name: varlog
          mountPath: /var/log
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
C
apiVersion: v1
kind: Pod
metadata:
  name: fluentd
spec:
  containers:
  - name: fluentd
    image: fluent/fluentd
    volumeMounts:
    - name: varlog
      mountPath: /var/log
  volumes:
  - name: varlog
    hostPath:
      path: /var/log
D
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: fluentd
spec:
  selector:
    matchLabels:
      name: fluentd
  serviceName: fluentd
  replicas: 1
  template:
    metadata:
      labels:
        name: fluentd
    spec:
      containers:
      - name: fluentd
        image: fluent/fluentd
        volumeMounts:
        - name: varlog
          mountPath: /var/log
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
Attempts:
2 left
💡 Hint

DaemonSets run one pod per node to collect logs from all nodes.

Troubleshoot
advanced
2:30remaining
Diagnosing missing logs in Kubernetes cluster

You notice that kubectl logs returns empty output for a pod, but the application writes logs to stdout. What is the most likely cause?

AThe container runtime is not writing logs to the expected location
BThe pod is running on a node without network connectivity
CThe pod's container image is missing the logging library
DThe Kubernetes API server is down
Attempts:
2 left
💡 Hint

Think about where logs come from when you run kubectl logs.

🔀 Workflow
expert
3:00remaining
Order of steps to implement centralized logging in Kubernetes

Arrange the steps in the correct order to set up centralized logging for a Kubernetes cluster using Fluentd and Elasticsearch.

A3,2,1,4
B2,3,1,4
C3,1,2,4
D1,3,2,4
Attempts:
2 left
💡 Hint

Think about creating a clean space first, then collecting logs, storing them, and finally visualizing.