Solve this question on: ssh cluster2-controlplane
In the cka-multi-containers namespace, proceed to create a pod named cka-sidecar-pod that adheres to the following specifications:
- The first container, labeled
main-container, is required to run thenginx:1.27, which writes the current date along with a greeting messageHi I am from Sidecar containerto/log/app.log. - The second container, identified as
sidecar-container, must use thenginx:1.25image and serve theapp.logfile as a webpage located at/usr/share/nginx/html.
Note: Do not rename app.log to index.html. The file name should remain app.log and be available at /app.log via the nginx server.
Solutions by lab
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: {}
I am not able to understand where its instructed that it continusesly writing date and message . for me instuction is asking to write only one time
( which writes the current date along with a greeting message Hi I am from Sidecar container to /log/app.log.)