Skip to content

Istio — alert on istio-proxy sidecar restart loop

An istio-proxy sidecar in a pod is restarting — the app keeps running, but mesh policy is broken, mTLS goes unchecked, and traffic flows in violation of policy.

Recipe

bash
#!/usr/bin/env bash
# /etc/cron.d/istio-sidecar
# */5 * * * * root /opt/istio-sidecar.sh

CONTEXT=${KUBE_CONTEXT:-prod}
THRESH=${THRESH:-3}                   # restarts in last hour

# Find pods where the istio-proxy container has restartCount delta > THRESH
HOTSPOTS=$(kubectl --context "$CONTEXT" get pods -A -o json \
  | jq --argjson t "$THRESH" '
      [.items[] |
       . as $p |
       .status.containerStatuses[]? |
       select(.name=="istio-proxy" and .restartCount >= $t) |
       {ns: $p.metadata.namespace, name: $p.metadata.name, restarts: .restartCount}]')

COUNT=$(echo "$HOTSPOTS" | jq 'length')

if [ "${COUNT:-0}" -gt 0 ]; then
  SUMMARY=$(echo "$HOTSPOTS" | jq -r '.[] | "\(.ns)/\(.name)=\(.restarts)"' | head -5 | tr '\n' ',')
  curl -fsS "$HEARTBEAT_URL" --data "sidecar_loops=$COUNT,examples=$SUMMARY"
  exit 2
fi
echo "OK (no sidecar loops)"

Same thing in Enterno.io

Wrap in an Enterno heartbeat — learn the sidecar is looping before traffic falls onto a non-mTLS path.

Set up HTTP monitor → ← All recipes

Related recipes