Skip to content

Instantly share code, notes, and snippets.

@groundnuty
Created April 22, 2019 16:26
Show Gist options
  • Save groundnuty/a10291492949de877ba26086ccdb44ea to your computer and use it in GitHub Desktop.
Save groundnuty/a10291492949de877ba26086ccdb44ea to your computer and use it in GitHub Desktop.
Benchmarking of k8s deployment
while IFS=',' read -r name sched ready compl initf ; do
name=$(echo $name | cut -d= -f2) ;
ready=$(echo $ready | cut -d= -f2);
sched=$(echo $sched | cut -d= -f2) ;
compl=$(echo $compl | cut -d= -f2) ;
initf=$(echo $initf | cut -d= -f2) ;
[ "$initf" = "null" ] && initf="" ;
s=$sched;
e=$ready;
[ "$initf" != "" ] && s=$initf ;
[ "$compl" != "" ] && e=$compl ;
#echo "$name\t$sched\t$ready\t$compl\t$initf\t$(datediff $s $e) " ;
echo "$name\t$(datediff $s $e) " ;
done < <(kubectl get pods -o json | jq -jr '.items[] | "name=","\(.metadata.name)",",scheduled=\(.status.conditions[] | select(.type == "PodScheduled") | .lastTransitionTime)",",ready=","\(.status.conditions[] | select(.type == "Ready") | .lastTransitionTime)",",completed=","\(.status.conditions[] | select((.type == "Initialized") and (.reason == "PodCompleted")) | .lastTransitionTime)",",initsFinished=","\(.status.initContainerStatuses[-1].state.terminated.finishedAt)\n"') | column -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment