Skip to content
Discussion options

You must be logged in to vote

Script to fix broken pods, run it from one of the other nodes:

#!/bin/sh
# Usage: `unblock.sh mynode`

kubectl get pods -A --field-selector spec.nodeName=$1 -o jsonpath='{range .items[*]}{.status.podIP} {.metadata.name} {.metadata.namespace}{"\n"}{end}' | while read -r line
do 
  ip=$(echo $line | cut -d" " -f1); 
  pod=$(echo $line | cut -d" " -f2)
  namespace=$(echo $line | cut -d" " -f3)
  ping ${ip} -c 1 -W 1 >/dev/null 2>&1
  if [ $? -eq 1 ]
  then
    echo "Pod ${pod} in namespace ${namespace} at address ${ip} is inaccessible, fixing ..."
    kubectl debug -n $namespace $pod -i --image=nicolaka/netshoot -- ping google.com -c 2
  else 
    echo "YAY! Pod ${pod} in namespace ${namespace}

Replies: 2 comments 14 replies

Comment options

You must be logged in to vote
10 replies
@brandond
Comment options

@drpump
Comment options

@drpump
Comment options

@drpump
Comment options

@drpump
Comment options

Comment options

You must be logged in to vote
4 replies
@drpump
Comment options

Answer selected by drpump
@drpump
Comment options

@brandond
Comment options

brandond Apr 5, 2026
Collaborator

@drpump
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants