Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dblackdblack/66b536fc65f0da4c1275a750954eb847 to your computer and use it in GitHub Desktop.
Save dblackdblack/66b536fc65f0da4c1275a750954eb847 to your computer and use it in GitHub Desktop.
restart pods script
#!/bin/bash -xe
do_kube() {
result=$(kubectl --kubeconfig ${KUBECONFIG} --context ${KUBECONTEXT} $cmd)
echo "$result"
}
for ns in $(cmd='get ns -l=istio-injection -o jsonpath="{.items[*].metadata.name}' do_kube) ; do
cmd="rollout restart deployment -n $ns" do_kube
cmd="rollout restart statefulsets -n $ns" do_kube
cmd="get rollout -n $ns -o name" do_kube
for rollout in $result ; do
cmd="-n $ns patch $rollout --patch {\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"kubectl.kubernetes.io/restartedAt\":\"$(date +\%s)\"}}}}} --type=merge" do_kube
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment