mirror of
https://github.com/sailor-sh/CK-X.git
synced 2026-07-11 00:29:20 +00:00
add: allow initContainers in accordance to k8s docs
This commit is contained in:
@@ -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