use exact match for sidecar container

This commit is contained in:
Fabian Hardt
2025-12-05 14:46:57 +01:00
parent 18e02d0d9d
commit b88dcd7f40

View File

@@ -7,7 +7,7 @@ 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")]}' 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")]}' 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
# Both containers have the volume mounted at the correct path