Argo CD

Argo CD
Terraform module for Kubernetes platforms

Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.

This Terraform module helps platform engineering teams provision Argo CD on Kubernetes. It fully integrates the upstream Kubernetes resources into the Terraform plan/apply lifecycle and allows configuring Argo CD using native Terraform syntax.

The Argo CD module is continuously updated and tested when new upstream versions are released.

Build status for argo-cd-v2.11.2-kbst.0

TL;DR:

  • Use kbst add service argo-cd to add Argo CD to your platform
  • The kbst CLI scaffolds the Terraform module boilerplate for you
  • Kubestack platform service modules bundle upstream manifests and are fully customizable

Use the module

The kbst CLI helps you scaffold the Terraform code to provision Argo CD on your platform. It takes care of calling the module once per cluster, and sets the correct source and latest version for the module. And it also makes sure the module's configuration and configuration_base_key match your platform.

# add Argo CD service to all platform clusters
kbst add service argo-cd
# or optionally only add Argo CD to a single cluster
# 1. list existing platform modules
kbst list
aks_gc0_westeurope
eks_gc0_eu-west-1
gke_gc0_europe-west1
# 2. add Argo CD to a single cluster
kbst add service argo-cd --cluster-name aks_gc0_westeurope

Scaffolding the boilerplate is convenient, but platform service modules are fully documented, standard Terraform modules. They can also be used standalone without the Kubestack framework.

Customize resources

All Kubestack platform service modules support the same module attributes and configuration as all Kubestack modules. The module configuration is a Kustomization set in the per environment configuration map following Kubestack's inheritance model.

The example below shows some options to customize the resources provisioned by the Argo CD module.

module "example_argo_cd" {
providers = {
kustomization = kustomization.example
}
source = "kbst.xyz/catalog/argo-cd/kustomization"
version = "2.11.2-kbst.0"
configuration = {
apps = {
+ # change the namespace of all resources
+ namespace = var.example_argo_cd_namespace
+
+ # or add an annotation
+ common_annotations = {
+ "terraform-workspace" = terraform.workspace
+ }
+
+ # use images to pull from an internal proxy
+ # and avoid being rate limited
+ images = [{
+ # refers to the 'pod.spec.container.name' to modify the 'image' attribute of
+ name = "container-name"
+
+ # customize the 'registry/name' part of the image
+ new_name = "reg.example.com/nginx"
+ }]
}
ops = {
+ # scale down replicas in ops
+ replicas = [{
+ # refers to the 'metadata.name' of the resource to scale
+ name = "example"
+
+ # sets the desired number of replicas
+ count = 1
+ }]
}
}
}

In addition to the example attributes shown above, modules also support secret_generator, config_map_generator, patches and many other Kustomization attributes.

Full documentation how to customize a module's Kubernetes resources is available in the platform service module configuration section of the framework documentation.

Argo CD Variants

Argo CD upstream provides manifests for normal and HA configurations. And each is available as either cluster wide or namespaced.

These are available as four variants in the Kubestack module.

  1. ha (default)
  2. ha-namespaced
  3. normal
  4. normal-namespaced

By default, the ArgoCD module provisions the HA variant which provisions 3 replicas of all Argo CD components. You can configure the desired variant per environment. Below example uses the HA variant for the apps environment. But the normal variant for the ops environment to use less memory and CPU.

module "example_argo_cd" {
providers = {
kustomization = kustomization.example
}
source = "kbst.xyz/catalog/argo-cd/kustomization"
version = "2.6.2-kbst.0"
configuration = {
apps = {}
ops = {
+ variant = "normal"
}
}
}

Getting started

After installing Argo CD from the catalog follow the getting started with Argo CD guide continuing with step 2.

For configuring access to the Argo CD API, consider the Ingress option using the Nginx ingress controller and Cert-manager from the catalog.