Skip to content

Instantly share code, notes, and snippets.

@shcallaway
Created August 28, 2019 17:55
Show Gist options
  • Select an option

  • Save shcallaway/3d43637747c70b7bceb423392c66bbf2 to your computer and use it in GitHub Desktop.

Select an option

Save shcallaway/3d43637747c70b7bceb423392c66bbf2 to your computer and use it in GitHub Desktop.
Re-run migration jobs in Kubernetes

If you have some migration jobs in Kubernetes, you can re-run them with this one-liner:

kubectl get jobs | grep migrations | awk '{print $1}' | xargs -I {} sh -c "kubectl get job {} -o json | jq 'del(.spec.selector)' | jq 'del(.spec.template.metadata.labels)' | kubectl replace --force -f -"

Based on this Stack Overflow answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment