Automation ArgoCD with CI Pipeline Using Image Updater

Another way to combine CI Pipeline with ArgoCD

Fauzan R
btech-engineering
4 min readMay 4, 2023

--

Introduction

ArgoCD

Argo CD is an open-source continuous delivery tool for Kubernetes that automates the deployment of your applications and infrastructure as code. With Argo CD, you can define your Kubernetes application manifests as declarative YAML files and store them in a version control system like Git. Argo CD then continuously monitors your Git repository for changes to your application manifests, and automatically deploys them to your Kubernetes cluster as needed.

Argo CD also provides a web-based user interface that allows you to view the status of your applications and infrastructure, and roll back to previous versions if needed. In addition, Argo CD can integrate with your existing CI/CD pipelines and GitOps workflows, providing a seamless and automated deployment experience.

ArgoCD Image Updater

Argo CD Image Updater is an optional component of Argo CD that automates the updating of container images in your Kubernetes deployments. It continuously scans your container image registry for new versions of your images and updates your Kubernetes deployment manifests with the latest image tags.

Argo CD Image Updater uses customizable strategies to perform image updates, including simple tag updates, canary releases, and blue-green deployments. You can configure it to work with a variety of image registries, including Docker Hub, Google Container Registry, and Amazon Elastic Container Registry.

Argo CD Image Updater simplifies the process of updating container images in your Kubernetes deployments and allows you to maintain a consistent and up-to-date application environment. By automating image updates, you can reduce the risk of manual errors and improve the efficiency of your DevOps processes.

Why?

argocd-image-updater is alternative way to combine CI pipeline and CD proses if you’re using ArgoCD. In another way, strategy to combine ArgoCD with CI pipeline is add new pipeline stages that will Pull -> Write -> Push deployment manifest to repository, after that it will trigger sync process ArgoCD for checking new version of deployment app.

Argo CD Image Updater provides a number of benefits over other ways of combining CI pipelines and Argo CD for image updates:

  1. Automated image updates: With Argo CD Image Updater, you can automate the process of updating container images in your Kubernetes deployments, which reduces the need for manual intervention and minimizes the risk of human error.
  2. Flexibility: Argo CD Image Updater supports a variety of image update strategies, including simple tag updates, canary releases, and blue-green deployments, so you can choose the strategy that works best for your specific use case.
  3. Integration with Argo CD: Argo CD Image Updater is designed to work seamlessly with Argo CD, so you can use a single tool to manage your Kubernetes deployments and image updates.
  4. Scalability: Argo CD Image Updater is designed to handle large-scale deployments with thousands of images and provides a number of performance optimizations to ensure that image updates are performed quickly and efficiently.

How?

Prerequisites

  • Kubernetes with argocd has installed
  • Account docker hub

Step-by-step

1. Install argocd-image-updater as plugin for existing argocd. You can install Argo CD Image Updater by running the following command:

helm install argocd-image-updater argo/argocd-image-updater — namespace argocd — set image.repository=<image_repo>

Replace <image_repo> with the image repository where you want to pull container images from, such as docker.io. This command installs the Image Updater pod and sets up the necessary RBAC permissions.

2. Configure your container image registry: You need to configure Argo CD Image Updater with the credentials for your container image registry, so it can pull the latest image versions. You can create a Kubernetes secret containing the registry credentials by running the following command:

kubectl create secret docker-registry <secret_name> --docker-server=<registry_url> --docker-username=<username> --docker-password=<password> --docker-email=<email>

Replace <secret_name> with a name for the secret, <registry_url> with the URL of your container image registry, <username> with your registry username, <password> with your registry password, and <email> with your email address.

then, you must add new ConfigMap for argocd-image-updater

apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-image-updater-config
data:
registries.conf: |
registries:
- name: Docker Hub
prefix: docker.io
api_url: https://registry-1.docker.io
credentials: secret:<secret_name>
defaultns: library
default: true

3. Configure your image update policy: You can configure your image update policy by adding an annotations section to your Argo CD application manifests. Here is an example annotations section that performs simple tag updates:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp
namespace: myapp
annotations:
argocd-image-updater.argoproj.io/image-list: myimage=some/image:latest
argocd-image-updater.argoproj.io//myimage.update-strategy: digest
argocd-image-updater.argoproj.io/write-back-method: git
argocd-image-updater.argoproj.io/git-branch: master
spec:
project: default
source:
repoURL: <repo_url>
path: myapp
destination:
server: https://kubernetes.default.svc
namespace: myapp
syncPolicy:
automated:
prune: true
selfHeal: true

Replace <repo_url> with the URL of your Git repository

4. Monitor and troubleshoot: Once you have set up Argo CD Image Updater, you can monitor its activity and troubleshoot any issues by checking the logs of the Image Updater pod and the Argo CD application controller pod. You can use kubectl to view the logs:

kubectl logs -f <pod_name>

Replace <pod_name> with the name of the pod you want to view logs for. You can also use the Argo CD UI to view the status of your applications and image updates.

Closing

implementing Argo CD Image Updater involves installing and configuring the Image Updater pod, configuring your image update policy, and configuring your container image registry. With Argo CD Image Updater, you can automate the updating of container images in your Kubernetes deployments, which simplifies the process of maintaining an up-to-date application environment

--

--