5.2 Kustomize

This lab explains how to use kustomize as manifest format together with Argo CD.

Kustomize Introduction

Kustomize introduces a template-free way to customize application configuration that simplifies the use of off-the-shelf applications. It is built into kubectl and oc with the command kubectl apply -k or oc apply -k.

It uses a concept called overlays, which allows to reduce redundant configuration for multiple stages (e.g. dev, prod, test) without a use of a template language.

Argo CD supports kustomize manifests out of the box.

Kustomize Overlays

When you want to use Kustomize with an overlay, you have to point the Argo Application to the Overlay

Kustomize Configuration

The following configuration options are available for Kustomize:

  • namePrefix is a prefix appended to resources for Kustomize apps
  • nameSuffix is a suffix appended to resources for Kustomize apps
  • images is a list of Kustomize image overrides
  • commonLabels is a string map of an additional labels
  • commonAnnotations is a string map of an additional annotations

Use the following command to set those parameters:

argocd app set argo-kustomize-$USER --nameprefix=<namePrefix>

Further Docs

Read more about the kustomize integration in the official documentation

Task 5.2.1: Deploy the simple-example with kustomize

Let’s deploy the simple-example from lab 1 using kustomize .

First you’ll have to create a new Argo CD application.

argocd app create argo-kustomize-$USER --repo https://gitea.training.cluster.acend.ch/$USER/argocd-training-examples.git --path 'kustomize/simple-example' --dest-server https://kubernetes.default.svc --dest-namespace $USER

Sync the application

Hint

To sync (deploy) the resources you can simply click sync in the web UI or execute the following command:

argocd app sync argo-kustomize-$USER

And verify the deployment:

kubectl get pod --namespace $USER --watch

Tell the application to sync automatically, to enable self-healing and auto-prune

Hint
argocd app set argo-kustomize-$USER --sync-policy automated
argocd app set argo-kustomize-$USER --self-heal
argocd app set argo-kustomize-$USER --auto-prune

Task 5.2.2: Set a configuration parameter

We can set the kustomize configuration parameter with the following command:

argocd app set argo-kustomize-$USER --nameprefix=acend

And take a look at the application in the web UI or using the command line tool

Hint
argocd app get argo-kustomize-$USER

Task 5.2.3: Create a second application representing the production stage

Let’s now also deploy an application for the production stage.

This does mean we deploy an overlay which specifically configures the production stage.

Let’s create the production stage Argo CD application (path: kustomize/overlays-example/overlays/production) with the name argo-kustomize-prod-$USER and enable automated sync, self-healing and pruning.

Hint
argocd app create argo-kustomize-prod-$USER --repo https://gitea.training.cluster.acend.ch/$USER/argocd-training-examples.git --path 'kustomize/overlays-example/overlays/production' --dest-server https://kubernetes.default.svc --dest-namespace $USER
argocd app set argo-kustomize-prod-$USER --sync-policy automated
argocd app set argo-kustomize-prod-$USER --self-heal
argocd app set argo-kustomize-prod-$USER --auto-prune

And verify the deployment:

kubectl get pod --namespace $USER --watch

Task 5.2.4: Delete the Applications

Delete the applications after you’ve explored the Argo CD Resources and the managed Kubernetes resources.

Hint
argocd app delete argo-kustomize-$USER
argocd app delete argo-kustomize-prod-$USER