Automatically pull new DigitalOcean container registry (DOCR) latest tags from Kubernetes
Problem
It is very common the latest
tag usage while storing images on container registries, for example on DOCR (DigitalOcean container registry).
So, how automatically pull new container images with tags that do not change over time (ex. latest
) while using DigitalOcean container registry?
Solution
Use Urunner for continuous deployment.
URunner is a lightweight Kubernetes utility in order to auto restart pods on image tag digest change.
How it works
Urunner is a standalone pod (running by default on urunner
namespace) that continuosly check changes on external container registries that support Docker API V2, for example DigitalOcean container registry (DOCR).
Urunner detects changes from container tags that don't change their names over time (like latest
)
When Urunner detects changes on Digital Ocean container registry DOCR (thanks to sha1 tag digest), automatically restart the specific deployment (the same of kubectl rollout restart deployment/<deployName>
)
Urunner stores its state on an internal sqllite db.
How to install Urunner
Prerequisites
- Kubernetes cluster (ex. Digital Ocean DOKS or any Kubernetes product you want)
- DigitalOcean container registry DOCR
Install Urunner
Create urunner-values.yaml
file.
image:
repository: ghcr.io/texano00/urunner
tag: 0.1.5
config:
URUNNER_CONF_FREQUENCY_CHECK_SECONDS: 5
URUNNER_CONF_CONTAINER_REGISTRY_TO_WATCH: registry.digitalocean.com
URUNNER_CONF_CONTAINER_REGISTRY_TYPE: digitalocean
secret:
create: true
digitalocean:
token: <replace-me-digitalocean-token>
<replace-me-digitalocean-token>
--> put there DigitalOcean token (follow below instructions to retrieve it)
How to retrieve DigitalOcean token
Go to https://cloud.digitalocean.com/account/api/tokens
Than follow below screenshots to generate a read only token for Urunner.
Helm install
helm upgrade --install urunner oci://ghcr.io/texano00/urunner/helm/urunner --version 0.1.0 --values urunner-values.yaml -n urunner --create-namespace
Labeling
Add urunner=enable
to all namespaces you want to be watched from Urunner.
kubectl label ns mynamespace urunner=enable
For full documentation --> https://github.com/texano00/urunner#configurable-watcher
Check the installation
Once Urunner detects a tag digest change, it will output the following row