I have done the task correctly but it still fails, I am attaching screenshot in this topic for your reference.
the question asks to create an init container I tried creating that but it goes in infinite loop and the main container is never executed, so i added the side-container as normal container but it still fails.
It would have helped if you had shared the YAML manifest you used to complete this task.
The sidecar container needs to be in initContainers with restartPolicy: Always set:
hello refer to my complete solutions for kk engineer kubernetes solutions and if it helps make sure to give a star to my repo . ![]()
and for your task this is solution https://github.com/MiqdadProjects/kodekloud-kubernetes-solutions/blob/main/LEVEL02/TASK02/Task-02-WebserverPod.md
complete solutions form level 1 to 4
Dear @MIQDAD ,
Thank you for your reply with the solution post but the solution shared by @Santosh_KodeKloud above works and your solution fails, why ?
I am assuming you have completed task and created the solution file in github a long time back when the question doesn’t ask to create the sidecar-container as initContainer so your solution works logically even I also tried the same but it fail to pass the solution test cases set by kodekloud.
You can check my 1st screenshot 3rd point in the question it asks to create initContainer.
So what does @Santosh_KodeKloud has it has restartPolicy: Always. Generally if a pod has initContainer then it executes and finishes first then starts the main container but in the question the command to be added in the initContainer runs for infinite time hence initContainer never completes and blocks the main container from running.
So what does restartPolicy: Always do ?
When the pod is getting created it firsts creates the initContainer. As restartPolicy is set to Always it treats this specially and it doesn’t wait for initContainer to complete but just waits for initContainer to start first, Once initContainer starts it goes to the main pod to start it and runs successfully both containers and KodeKloud Engineer team has smartly added one line in the 5th point that is “Ensure all containers are in a running state”.



