Hi Team,
I am facing an issue with the Kubernetes Sidecar Pattern task and need help verifying the expected solution.
Task says to create:
- a regular nginx container
- an init container named
sidecar-container
with this command:
"sh","-c","while true; do cat /var/log/nginx/access.log /var/log/nginx/error.log; sleep 30; done"
I created the following YAML based on the task description:
apiVersion: v1
kind: Pod
metadata:
name: webserver
spec:
volumes:
- name: shared-logs
emptyDir: {}
initContainers:
- 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
containers:
- name: nginx-container
image: nginx:latest
volumeMounts:
- name: shared-logs
mountPath: /var/log/nginx
But the pod remains stuck in:
Init:0/1
because the init container never exits due to the infinite loop.
Could someone please confirm whether:
- the task really expects an initContainer, or
- sidecar-container should actually be a normal running container instead?
Thanks.