mirror of
https://github.com/sailor-sh/CK-X.git
synced 2026-02-14 17:39:51 +00:00
Merge pull request #55 from FabianHardt/fix/ckad-lab2-q2
fix CKAD lab2 question 2
This commit is contained in:
@@ -62,6 +62,9 @@ spec:
|
||||
volumeMounts:
|
||||
- name: log-volume
|
||||
mountPath: /var/log
|
||||
- name: log-volume
|
||||
mountPath: /var/log/nginx
|
||||
subPath: nginx
|
||||
- name: sidecar-container
|
||||
image: busybox
|
||||
command: ['sh', '-c', 'while true; do echo $(date) >> /var/log/app.log; sleep 5; done']
|
||||
|
||||
@@ -6,10 +6,10 @@ VOLUME_NAME=$(kubectl get pod multi-container-pod -n multi-container -o jsonpath
|
||||
|
||||
if [[ "$VOLUME_NAME" == "log-volume" ]]; then
|
||||
# Volume exists, now check if it's mounted in both containers
|
||||
MAIN_CONTAINER_MOUNT=$(kubectl get pod multi-container-pod -n multi-container -o jsonpath='{.spec.containers[?(@.name=="main-container")].volumeMounts[?(@.name=="log-volume")].mountPath}' 2>/dev/null)
|
||||
MAIN_CONTAINER_MOUNT=$(kubectl get pod multi-container-pod -n multi-container -o jsonpath='{.spec.containers[?(@.name=="main-container")].volumeMounts[?(@.name=="log-volume")]}' 2>/dev/null)
|
||||
SIDECAR_CONTAINER_MOUNT=$(kubectl get pod multi-container-pod -n multi-container -o jsonpath='{.spec.containers[?(@.name=="sidecar-container")].volumeMounts[?(@.name=="log-volume")].mountPath}' 2>/dev/null)
|
||||
|
||||
if [[ "$MAIN_CONTAINER_MOUNT" == "/var/log" && "$SIDECAR_CONTAINER_MOUNT" == "/var/log" ]]; then
|
||||
if [[ "$MAIN_CONTAINER_MOUNT" == *"/var/log"* && "$SIDECAR_CONTAINER_MOUNT" == "/var/log" ]]; then
|
||||
# Both containers have the volume mounted at the correct path
|
||||
exit 0
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user