auto-update your cluster: sync your docker images and restart pods running on outdated images
auto-update your cluster: check your pods for outdated images, trigger rolling deployment of new pods when needed
!!! DO NOT USE IN A PRODUCTION ENVIRONMENT !!!
bad things could happen: service downtime, permanent pod restarts, hailstorms, … You have been warned!
helm install --name auto-updater \
https://arnehilmann.github.io/k8s-auto-updater/k8s-auto-updater-0.2.0.tgz \
--set podSelector=
# cross fingers
in your clusterk8s-auto-updater
runs as a cronjob inside your kubernetes-cluster.
with the authorityk8s-auto-updater
uses skopeo
and kubectl
, and
has the following permissions:
resource | verb |
---|---|
pods | list, get |
secrets | get |
replicasets | get |
deployments | get, patch |
gathering image names and its digestsk8s-auto-updater
fetches all pods and corresponding image names:
1) image name must match imageRegExp
(default: .*
, see #Notes)
2) pod labels must match podSelector
(default: auto-update=enabled
, see #Notes).
rolling update of deployments
Then k8s-auto-updater
iterates over selected pods, checking if the image id the pod was started on equals
the image id referenced by the image name. If the image id of the pod differs, the
owning replicaset and deployment get identified and then the deployment env gets patched, resulting
in a new replicaset and thus newly started pods.
A more permanent setup would be to add this repo to your helm installation and
install k8s-auto-updater
from there (see the config part for customization):
helm repo add k8s-a-u-chart https://arnehilmann.github.io/k8s-auto-updater/
helm install --name auto-updater k8s-a-u-chart/k8s-auto-updater
The following parameters could be set via --set
:
parameter | default | description |
---|---|---|
schedule | */10 * * * * | when to run k8s-auto-updater , uses cron syntax |
suspend | false | should k8s-auto-updater run on startup or stay in suspend mode |
activeDeadlineSeconds | 300 | hard timeout for the job |
podSelector | auto-update=enabled | select pods based on labels; supports ‘=’, ‘!=’ |
imageRegExp | .* | regular expression for matching docker images |
verbose | false | produce more detailed log output |
example:
helm install --name auto-updater \
k8s-a-u-chart/k8s-auto-updater \
--set schedule="*/2 * * * *" \ # run every two minutes
--set podSelector= # select _all_ pods in current namespace
podSelector
variable might be a bad ideaimageRegExp
;pattern1|pattern2
notation; e.g.... --set imageRegExp='arne/d.*|gitlab.*'
.docker.io
, the host part of the image name is emptyarne/k8s-auto-updater
instead of docker.io/arne/k8s-auto-updater
).docker.io
, the host and repo parts are emptymysql
instead of docker.io/library/mysql
).
helm delete auto-updater
find the current chart index at
https://arnehilmann.github.io/k8s-auto-updater/index.yaml
find the docker image at
https://hub.docker.com/r/arne/kubectlskopeo/