Skip to content

Instantly share code, notes, and snippets.

@viggin543
Created April 17, 2020 18:25
Show Gist options
  • Save viggin543/01b6e87e675c4b76d67e9d2bfccdb32d to your computer and use it in GitHub Desktop.
Save viggin543/01b6e87e675c4b76d67e9d2bfccdb32d to your computer and use it in GitHub Desktop.
a script that messures the time it takes to a single pod to become redy
#!/usr/bin/env bash
pod=$1
scheduled=`kubectl get pod $pod -o json | jq -r '.status.conditions[] | select(.type=="PodScheduled") | .lastTransitionTime' | sed 's/T/ /g' | tr -d 'Z'`
ready=`kubectl get pod $pod -o json | jq -r '.status.conditions[] | select(.type=="Ready") | .lastTransitionTime' | sed 's/T/ /g' | tr -d 'Z'`
scheduled_epoch=`date -j -u -f "%Y-%m-%d %T" "$scheduled" "+%s"` # mac os date ( linux has different
echo "${pod} sechedualed at ${scheduled_epoch}"
ready_epoch=`date -j -u -f "%Y-%m-%d %T" "$ready" "+%s"`
load_seconds=$((ready_epoch-scheduled_epoch))
echo "${pod} launch time: ${load_seconds} seconds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment