Sidecar lab issue: initContainer vs sidecar container conflict

Hi,

I’m working on the Kubernetes Sidecar lab and noticed a contradiction in the task.

The description says to implement a Sidecar pattern for log shipping, which should be a regular container running alongside nginx.

However, the instructions say to create an init container named “sidecar-container” using ubuntu:latest.

The command provided:
while true; do cat /var/log/nginx/access.log /var/log/nginx/error.log; sleep 30; done

This command runs forever, which works for a sidecar container but not for an init container (since init containers must exit before the main container starts).

What I observed:

  • If I use a regular container → Pod runs fine (2/2 Running) but checker fails saying sidecar-container doesn’t exist
  • If I use initContainer → Pod gets stuck in Init state because the command never exits
  • If I modify the command to exit → Pod runs but no longer behaves like a sidecar

So it seems like:

  • The task expects sidecar behavior
  • But the checker expects an initContainer

It shows two errors when checked:

  • sidecar-container does not exist
  • ubuntu:latest is not used in sidecar-container

Can you please confirm which one is correct?

Thanks.

This is The yaml configuration I used:

apiVersion: v1
kind: Pod
metadata:
name: webserver
spec:
volumes:

  • name: shared-logs
    emptyDir: {}
    containers:
  • name: nginx-container
    image: nginx:latest
    volumeMounts:
    • name: shared-logs
      mountPath: /var/log/nginx
  • name: sidecar-container
    image: ubuntu:latest
    command: [“sh”,“-c”,“while true; do cat /var/log/nginx/access.log /var/log/nginx/error.log; sleep 30; done”]
    volumeMounts:
    • name: shared-logs
      mountPath: /var/log/nginx

Sidecar container, as defined in official docs, says: Kubernetes implements sidecar containers as a special case of init containers; sidecar containers remain running after Pod startup.

Sidecar container is a container placed in initContainers which can now have a restartPolicy set to Always. This restarts the container on failure, enabling it to run alongside main container/s.

Thank you for replying. I’ve finished the lab now. Very stupid of me for not reading the official documentation. I’ve learnt a lesson for future.