Skip to content

Instantly share code, notes, and snippets.

@akaron
Created February 9, 2022 09:14
Show Gist options
  • Save akaron/f4811003021ee69c85c67c9d775af013 to your computer and use it in GitHub Desktop.
Save akaron/f4811003021ee69c85c67c9d775af013 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# modified from: https://itnext.io/how-to-cold-start-fast-a-java-service-on-k8s-eks-3a7b4450845d
ns=$1
pod=$2
scheduled=`kubectl -n $ns get pod $pod -o json | jq -r '.status.conditions[] | select(.type=="PodScheduled") | .lastTransitionTime' | sed 's/T/ /g' | tr -d 'Z'`
ready=`kubectl -n $ns get pod $pod -o json | jq -r '.status.conditions[] | select(.type=="Ready") | .lastTransitionTime' | sed 's/T/ /g' | tr -d 'Z'`
scheduled_epoch=`date -u -d "$scheduled" +%s`
echo "${pod} sechedualed at ${scheduled_epoch}"
ready_epoch=`date -u -d "$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