Skip to content

Instantly share code, notes, and snippets.

@nottrobin
Last active March 14, 2019 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nottrobin/2cc84fa4e0426be06cd603c00dac59ba to your computer and use it in GitHub Desktop.
Save nottrobin/2cc84fa4e0426be06cd603c00dac59ba to your computer and use it in GitHub Desktop.
Get first non-ready kubernetes pod
app=maas.io
deployment_failed_reason=$(kubectl get deployment --namespace staging --selector app=${app} -o=jsonpath='{.items[0].status.conditions[1].reason}')
if [ "${deployment_failed_reason}" == "ProgressDeadlineExceeded" ]; then
non_ready_pod=$(kubectl get pod --namespace staging --selector app=${app} --output json | jq -r '(.items | map(select(.status.containerStatuses[0].ready==false)))[0].metadata.name')
kubectl logs ${non_ready_pod} --namespace staging
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment