Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adopt Deployment Pod resources into a Helm install
# Can use https://gist.github.com/magickatt/e7885f748c2ecd5bb88dd64828b30fbf
# to adopt the Deployment resources themselves
NAME=test
NAMESPACE=default
kubectl get -n $NAMESPACE deployment -o name \
| xargs -I % kubectl patch -n $NAMESPACE % -p \
'{"spec": {"template":{"metadata":{"annotations":{"meta.helm.sh/release-name": "$NAME"}}}}}'
kubectl get -n $NAMESPACE deployment -o name \
| xargs -I % kubectl patch -n $NAMESPACE % -p \
'{"spec": {"template":{"metadata":{"annotations":{"meta.helm.sh/release-namespace": "$NAMESPACE"}}}}}'
kubectl get -n $NAMESPACE deployment -o name \
| xargs -I % kubectl patch -n $NAMESPACE % -p \
'{"spec": {"template":{"metadata":{"labels":{"app.kubernetes.io/managed-by": "Helm"}}}} }'
# Roll all the Deployments so the Pod resources are refreshed
for DEPLOY in `kubectl get deployments -n $NAMESPACE | tail -n +2 | cut -d ' ' -f 1`; do
kubectl rollout restart deployments/$DEPLOY -n $NAMESPACE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment