mirror of
https://github.com/sailor-sh/CK-X.git
synced 2026-08-18 02:46:24 +00:00
Merge pull request #33 from soeguet/fix/ckad-001-q6
add: allow initContainers as sidecar container
This commit is contained in:
+5
@@ -11,10 +11,15 @@ fi
|
||||
# Verify container names
|
||||
NGINX_CONTAINER=$(kubectl get pod sidecar-pod -n troubleshooting -o jsonpath='{.spec.containers[?(@.name=="nginx")].name}' 2>/dev/null)
|
||||
SIDECAR_CONTAINER=$(kubectl get pod sidecar-pod -n troubleshooting -o jsonpath='{.spec.containers[?(@.name=="sidecar")].name}' 2>/dev/null)
|
||||
SIDECAR_INITCONTAINER=$(kubectl get pod sidecar-pod -n troubleshooting -o jsonpath='{.spec.initContainers[?(@.name=="sidecar")].name}' 2>/dev/null)
|
||||
SIDECAR_INITCONTAINER_CONDITION=$(kubectl get pod sidecar-pod -n troubleshooting -o jsonpath='{.spec.initContainers[?(@.name=="sidecar")].restartPolicy}' 2>/dev/null)
|
||||
|
||||
if [ -n "$NGINX_CONTAINER" ] && [ -n "$SIDECAR_CONTAINER" ]; then
|
||||
echo "Success: Pod has both 'nginx' and 'sidecar' containers"
|
||||
exit 0
|
||||
elif [ -n "$NGINX_CONTAINER" ] && [ -n "$SIDECAR_INITCONTAINER" ] && [ "$SIDECAR_INITCONTAINER_CONDITION" = "Always" ]; then
|
||||
echo "Success: Pod has 'nginx' container and 'sidecar' init container with restartPolicy 'Always'"
|
||||
exit 0
|
||||
else
|
||||
echo "Error: Pod does not have the required container names ('nginx' and 'sidecar')"
|
||||
echo "Found containers with names: $(kubectl get pod sidecar-pod -n troubleshooting -o jsonpath='{.spec.containers[*].name}' 2>/dev/null)"
|
||||
|
||||
Reference in New Issue
Block a user