How to "deploy" in kubernetes without any changes, just to get pods to cycle
According to documentation:
Note: a Deployment’s rollout is triggered if and only if the Deployment’s pod template (i.e.
.spec.template
) is changed, e.g. updating labels or container images of the template.
You can just use kubectl patch
to update i.e. a label inside .spec.template
.
As of kubectl 1.15, you can run:
kubectl rollout restart deployment <deploymentname>
What this does internally, is patch the deployment with a kubectl.kubernetes.io/restartedAt
annotation so the scheduler performs a rollout according to the deployment update strategy.
For previous versions of Kubernetes, you can simulate a similar thing:
kubectl set env deployment --env="LAST_MANUAL_RESTART=$(date +%s)" "deploymentname"
And even replace all in a single namespace:
kubectl set env --all deployment --env="LAST_MANUAL_RESTART=$(date +%s)" --namespace=...