Hello,
The below is from Ultimate CKA Mock exam series , Exam 5- Question 4.
The YAML file I created is the same as the YAML in the Exam solution.
I have checked multiple times and I cannot find any difference between the two.
kubectl apply -f filename.yaml is successful but it eventually fails to create the main container.
Please help identify what is missing in the below YAML file.
apiVersion: v1
kind: Pod
metadata:
name: cka-sidecar-pod
namespace: cka-multi-containers
spec:
containers:
- name: main-container
image: nginx:1.27
command: [“/bin/sh”]
args:
- -c
- |
- while true; do
echo “$(date) Hi I am from Sidecar container” >> /log/app.log;
sleep 5;
done
volumeMounts:
- name: shared-logs
mountPath: /log
- name: sidecar-container
image: nginx:1.25
volumeMounts:
- name: shared-logs
mountPath: /usr/share/nginx/html
volumes:
- name: shared-logs
emptyDir: {}
============================
The warning message and the log are:
Warning BackOff 45s (x47 over 10m) kubelet Back-off restarting failed container main-container in pod cka-sidecar-pod_cka-multi-containers(e34259a2-4cee-4ac9-9b15-f47c813d4b5e)
cluster2-controlplane ~ âžś kubectl get pod -n cka-multi-containers
NAME READY STATUS RESTARTS AGE
cka-sidecar-pod 1/2 CrashLoopBackOff 7 (39s ago) 11m
cluster2-controlplane ~ âžś kubectl -n cka-multi-containers logs cka-sidecar-pod
Defaulted container “main-container” out of: main-container, sidecar-container
cluster2-controlplane ~ âžś