Hi KodeKloud Team,
I am facing an issue with the “Sidecar Pattern” Kubernetes task.
The task asks to:
-
Create a pod named
webserver -
Create an
emptyDirvolume namedshared-logs -
Create:
- a regular container
nginx-containerusingnginx:latest - an init container
sidecar-containerusingubuntu:latest
- a regular container
-
Add this command to the sidecar container:
"sh","-c","while true; do cat /var/log/nginx/access.log /var/log/nginx/error.log; sleep 30; done"
The problem is:
-
sidecar-containeris defined as aninitContainer - but the command contains
while true - init containers never complete because of the infinite loop
- therefore the main nginx container never starts
- pod remains stuck in:
Init:0/1
If I move sidecar-container to regular containers, the pod works correctly (2/2 Running), but the validator fails saying the init container does not exist.
Could you please clarify whether:
-
sidecar-containershould actually be a regular container instead of an init container? - or if the validator/task definition needs correction?
Thanks.