Skip to content

Commit 14a11a5

Browse files
committed
Added Argo CD Image Updater with Helm
Signed-off-by: Aryan Shah <[email protected]>
1 parent 5360497 commit 14a11a5

File tree

16 files changed

+489
-0
lines changed

16 files changed

+489
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: "Configuring Argo CD Image Updater with Helm"
3+
description: "This challenge provides a walkthrough on automating Kubernetes deployments by integrating Argo CD Image Updater with Helm."
4+
weight: 3
5+
id: "9136f21d-c87f-478a-8f8b-6687597a2841"
6+
banner: "kubernetes-icon.svg"
7+
categories: "kubernetes"
8+
---
9+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
id: "argo-cd-image-updater-binary"
3+
title: 'Argo CD Image Updater Binary'
4+
description: ""
5+
weight: 7
6+
---
7+
8+
The **argocd-image-updater** binary and specifically the **test** subcommand provides a variety of test options, including testing registry access, multi-arch images, semver constrains, update strategies, and credentials before configuring annotations on your Argo CD applications. It is available in the **argocd-image-updater** pod or you can install it locally. Here are the **argocd-image-updater** test command options:
9+
10+
11+
```
12+
Flags:
13+
14+
--allow-tags string only consider tags in registry that satisfy the match function
15+
--credentials string the credentials definition for the test (overrides registry config)
16+
--disable-kubernetes whether to disable the Kubernetes client
17+
--disable-kubernetes-events Disable kubernetes events
18+
-h, --help help for test
19+
--ignore-tags stringArray ignore tags in registry that match given glob pattern
20+
--kubeconfig string path to your Kubernetes client configuration
21+
--loglevel string log level to use (one of trace, debug, info, warn, error) (default "debug")
22+
--platforms strings limit images to given platforms (default [linux/amd64])
23+
--rate-limit int specify registry rate limit (overrides registry.conf) (default 20)
24+
--registries-conf-path string path to registries configuration
25+
--semver-constraint string only consider tags matching semantic version constraint
26+
--update-strategy string update strategy to use, one of: semver, latest (default "semver")
27+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
id: "conclusions"
3+
title: 'Conclusions'
4+
description: ""
5+
weight: 10
6+
---
7+
8+
The Argo CD Image Updater is a powerful tool that enhances the continuous delivery process in Kubernetes environments. Automating the process of updating container images not only streamlines deployments but also reduces the risk of human error associated with manual updates.
9+
10+
Moreover, its flexibility allows developers to tailor the update policies to suit their specific workflows, ensuring that only the necessary updates are applied. This ultimately leads to improved application reliability and performance.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
id: "configuration-and-setup"
3+
title: 'Configuration and Setup'
4+
description: ""
5+
weight: 3
6+
---
7+
8+
In this example implementation, we are using the official [argocd-image-updater](https://github.com/argoproj/argo-helm/tree/main/charts/argocd-image-updater) Helm chart. It is deployed as an **argocd** application in the same cluster and namespace as Argo CD:
9+
10+
```yaml
11+
apiVersion: argoproj.io/v1alpha1
12+
kind: Application
13+
metadata:
14+
name: argocd-image-updater
15+
namespace: argocd
16+
spec:
17+
destination:
18+
namespace: argocd
19+
server: https://kubernetes.default.svc(opens in a new tab)
20+
project: 'applications'
21+
source:
22+
helm:
23+
valueFiles:
24+
- ../argocd-image-updater/values.yaml
25+
path: helm/argocd-image-updater
26+
repoURL: https://gitlab.org.com/demo.git
27+
targetRevision: HEAD
28+
syncPolicy:
29+
automated:
30+
prune: true
31+
selfHeal: true
32+
allowEmpty: false
33+
syncOptions:
34+
revisionHistoryLimit: 3
35+
```
36+
37+
Let’s review the **values** file, where we will explore some of the essential configuration options required. These options are critical to ensuring proper functionality and deployment of the service.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
id: "enabling-service-account-and-RBAC-creation"
3+
title: 'Enabling the Service Account and RBAC Creation'
4+
description: ""
5+
weight: 5
6+
---
7+
8+
```yaml
9+
rbac:
10+
# -- Enable RBAC creation
11+
enabled: true
12+
13+
serviceAccount:
14+
# -- Specifies whether a service account should be created
15+
create: true
16+
# -- Annotations to add to the service account
17+
annotations: {}
18+
# -- Labels to add to the service account
19+
labels: {}
20+
# -- The name of the service account to use.
21+
# If not set and create is true, a name is generated using the fullname template
22+
name: ""
23+
```
24+
25+
---
26+
27+
- **ServiceAccount** provides the necessary identity for ArgoCD Image Updater to authenticate and interact with the Kubernetes API to perform updates on deployment manifests or Helm charts (e.g., changing container image tags).
28+
29+
- **rbac** ensures that ArgoCD Image Updater is granted only the permissions it needs, helping to secure your cluster by restricting its access and reducing the attack surface.
30+
31+
---
32+
33+
Without enabling both, the ArgoCD Image Updater would either lack the permissions to modify Kubernetes resources (failing to update your applications) or could have overly broad permissions, which could be a security risk.
34+
35+
In the default installation scenario, i.e., Argo CD Image Updater installed to the `argocd` namespace, no further configuration is needed for Argo CD Image Updater to access the Kubernetes API. If your Argo CD installation is in a different namespace than `argocd`, you must adapt the **RoleBinding** to bind to the **ServiceAccount** in the correct namespace.
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
id: "log-level"
3+
title: 'Log Level'
4+
description: ""
5+
weight: 6
6+
---
7+
8+
```yaml
9+
# -- Argo CD Image Update log level
10+
logLevel: "debug"
11+
```
12+
13+
Changing the log level from `"info"` to `"debug"` in the Argo CD Image Updater `values` file can be beneficial in certain scenarios where you need deeper insights into the system’s behavior.
14+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
id: "Overview"
3+
title: 'Overview'
4+
description: ""
5+
weight: 1
6+
---
7+
8+
This challenge provides a walkthrough on automating Kubernetes deployments by integrating Argo CD Image Updater with Helm. It details the setup process, including configuring container registries like Amazon ECR and GitHub Container Registry, and emphasizes the importance of proper authentication and role-based access control (RBAC) to ensure secure and efficient operations. It also explores various update strategies—such as semantic versioning (semver), latest, digest, and name—demonstrating how to annotate Argo CD applications to enable these strategies effectively.
9+
10+
### Understanding Argo CD Image Updater
11+
12+
In modern Kubernetes environments, managing container images and ensuring that applications are always running the latest, most secure versions can be daunting. Argo CD Image Updater simplifies this process by automatically checking for new container image versions and updating your applications accordingly. Integrating seamlessly with Argo CD enables fully automated updates to Kubernetes workloads.
13+
14+
The beauty of Argo CD Image Updater lies in its simplicity and flexibility. The Image Updater takes over the heavy lifting by annotating your Argo CD application resources with a list of images and defining version constraints. It regularly polls for new image versions from your container registry, checks if they meet the specified constraints, and updates your applications automatically.
15+
16+
Argo CD Image Updater also offers a range of advanced features, such as support for Helm and Kustomize-based applications, various update strategies (like semver, latest, name, and digest), and seamless integration with private container registries. Additionally, it allows parallel updates and supports filtering tags with custom matchers, making it highly customizable and suitable for both small and large-scale Kubernetes environments.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
id: "registries"
3+
title: 'Registries'
4+
description: ""
5+
weight: 4
6+
---
7+
8+
Let's configure the container registries that we are using. Argo CD Image Updater supports the majority of container registries (public and private), that implement Docker registry v2 API and has been tested against registries such as Docker Hub, Docker Registry v2 reference implementation (on-premise), Red Had Quay, Jfrog Artifactory, Github Container Registry, GitHub Packages Registry, GitLab Container Registry, and Google Container Registry.
9+
10+
In the following examples, we will configure two of the most widely used container registries – Amazon Elastic Container Registry (ECR) and GitHub Container Registry (GHCR). In our case, we are working with private registries to ensure secure storage and access control for container images.
11+
12+
13+
### Amazon Elastic Container Registry (ECR) configuration
14+
15+
```yaml
16+
registries:
17+
- name: ECR
18+
api_url: https://000000000000.dkr.ecr.eu-west-1.amazonaws.com
19+
prefix: 000000000000.dkr.ecr.eu-west-1.amazonaws.com
20+
ping: yes
21+
insecure: false
22+
credentials: ext:/scripts/login.sh
23+
credsexpire: 10h
24+
```
25+
26+
For Amazon Elastic Container Registry, authentication is possible through a script that executes an API call to retrieve the necessary credentials. In the values file, we can include this script in the **authScripts** section:
27+
28+
```yaml
29+
authScripts:
30+
# -- Whether to mount the defined scripts that can be used to authenticate with a registry, the scripts will be mounted at `/scripts`
31+
enabled: true
32+
# -- Map of key-value pairs where the key consists of the name of the script and the value the contents
33+
scripts:
34+
login.sh: |
35+
#!/bin/sh
36+
aws ecr --region "eu-west-1" get-authorization-token --output text --query 'authorizationData[].authorizationToken' | base64 -d
37+
```
38+
39+
The script is executed by the pod and is responsible for obtaining the ECR authorization token. We use a role attached to our EKS node group, which includes the AWS-managed policy **AmazonEC2ContainerRegistryReadOnly**. This policy permits the **GetAuthorizationToken** API call:
40+
41+
42+
```
43+
{
44+
"Version": "2012-10-17",
45+
"Statement": [
46+
{
47+
"Effect": "Allow",
48+
"Action": [
49+
"ecr:GetAuthorizationToken",
50+
"ecr:BatchCheckLayerAvailability",
51+
"ecr:GetDownloadUrlForLayer",
52+
"ecr:GetRepositoryPolicy",
53+
"ecr:DescribeRepositories",
54+
"ecr:ListImages",
55+
"ecr:DescribeImages",
56+
"ecr:BatchGetImage",
57+
"ecr:GetLifecyclePolicy",
58+
"ecr:GetLifecyclePolicyPreview",
59+
"ecr:ListTagsForResource",
60+
"ecr:DescribeImageScanFindings"
61+
],
62+
"Resource": "*"
63+
}
64+
```
65+
66+
### Github Container Registry configuration
67+
68+
```yaml
69+
registries:
70+
- name: GitHub Container Registry
71+
api_url: https://ghcr.io
72+
73+
prefix: ghcr.io
74+
75+
ping: yes
76+
77+
credentials: secret:argocd/ghcr-secret#token
78+
```
79+
80+
For registry authentication, in the credentials section, we are using a Kubernetes secret. The **#token** part refers to the specific key (usually containing a personal access token or authentication token) inside the secret. The token must have at least **read:packages** permissions. Here is a manifest of the Kubernetes secret which has to be applied in the **argocd** namespace:
81+
82+
```yaml
83+
apiVersion: v1
84+
kind: Secret
85+
metadata:
86+
name: ghcr-secret3
87+
namespace: argocd
88+
89+
stringData:
90+
token: user_name:access_token
91+
```
92+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
id: "update-methods"
3+
title: 'Update Methods'
4+
description: ""
5+
weight: 8
6+
---
7+
8+
Argo CD Image Updater supports two write-back methods for propagating new image versions to Argo CD.
9+
10+
- **argocd**:
11+
Directly modifies the Argo CD application resource via Kubernetes or the Argo CD API, depending on the configuration.
12+
13+
- **git**: Creates a Git commit in the application’s repository with the updated image information.
14+
15+
The write-back method and its configuration are set per application, with further configuration options available depending on the method used.
16+
17+
18+
19+
> In this microcourse, the examples are applied using the **argocd update** method, which is the default update method and does not need further configuration. For **production environments**, it is recommended to use the **git update** method to persist the changes made by **Argo CD Image Updater** in your git repository.

0 commit comments

Comments
 (0)