Create a Pod with main container busybox and which executes this "while true; do echo `Hi I am from Main container’ >> /var/log/index.html; sleep 5; done" and with sidecar container with nginx image which exposes on port 80. Use emptyDir Volume and mount this volume on path /var/log for busybox and on path /usr/share/nginx/html for nginx container. Verify both containers are running.

Create a Pod with main container busybox and which executes this "while true; do echo `Hi I am from Main container’ >> /var/log/index.html; sleep 5; done" and with sidecar container with nginx image which exposes on port 80. Use emptyDir Volume and mount this volume on path /var/log for busybox and on path /usr/share/nginx/html for nginx container. Verify both containers are running.
A . Solution:
// create an initial yaml file with this
kubectl run multi-cont-pod –image=busbox –restart=Never — dry-run -o yaml > multi-container.yaml
// edit the yml as below and create it
kubectl create -f multi-container.yaml
vim multi-container.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
run: multi-cont-pod
name: multi-cont-pod
spec:
volumes:
– name: var-logs
emptyDir: {}
containers:
– image: busybox
command: ["/bin/sh"]
args: ["-c", "while true; do echo ‘Hi I am from Main container’ >> /var/log/index.html; sleep 5;done"]
name: main-container
volumeMounts:
– name: var-logs
mountPath: /var/log
– image: nginx
name: sidecar-container
ports:
– containerPort: 80
volumeMounts:
– name: var-logs

mountPath: /usr/share/nginx/html
restartPolicy: Never
// Create Pod
kubectl apply -f multi-container.yaml
//Verify
kubectl get pods

Answer: A

Latest CKA Dumps Valid Version with 122 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments