Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 7e22bb56 authored by Kevin Coleman's avatar Kevin Coleman
Browse files

Adding support for ArgoCD bootstrap apps.

parent ba093474
No related branches found
No related tags found
No related merge requests found
......@@ -3,25 +3,49 @@
[ArgoCD](https://argo-cd.readthedocs.io/en/stable/) Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.
Application definitions, configurations, and environments should be declarative and version controlled. Application deployment and lifecycle management should be automated, auditable, and easy to understand.
## Usage
ArgoCD can be deployed by enabling the add-on via the following.
```hcl
#---------------------------------------
# ENABLE ARGOCD
#---------------------------------------
argocd_enable = true
# Optional Map value - Override values.yaml for Argo CD
argocd_helm_chart = {
name = "argo-cd"
chart = "argo-cd"
repository = "https://argoproj.github.io/argo-helm"
version = "3.26.3"
namespace = "argocd"
timeout = "1200"
create_namespace = true
values = [templatefile("${path.module}/argocd-values.yaml", {})]
}
#---------------------------------------
# ENABLE ARGOCD
#---------------------------------------
argocd_enable = true
```
You can optionally customize the Helm chart that deploys ArgoCD via the following configuration.
```hcl
argocd_helm_chart = {
name = "argo-cd"
chart = "argo-cd"
repository = "https://argoproj.github.io/argo-helm"
version = "3.26.3"
namespace = "argocd"
timeout = "1200"
create_namespace = true
values = [templatefile("${path.module}/argocd-values.yaml", {})]
}
```
### Boostrapping
The framework provides an approach to bootstraping workloads and/or additional add-ons by leveraging the ArgoCD [App of Apps](https://argo-cd.readthedocs.io/en/stable/operator-manual/cluster-bootstrapping/) pattern.
The following code example demonstrates how you can supply information for a repository in order to bootstrap multiple workloads in a new EKS cluster. The example leverages a [sample App of Apps repository](https://github.com/aws-samples/ssp-eks-workloads.git) that ships with the EKS SSP solution.
```hcl
argocd_applications = {
workloads = {
namespace = "argocd"
repo_path = "envs/dev"
repo_url = "https://github.com/aws-samples/ssp-eks-workloads.git"
target_revision = "HEAD"
destination = "https://kubernetes.default.svc"
project = "default"
values = {}
}
}
```
\ No newline at end of file
......@@ -140,9 +140,10 @@ module "aws_opentelemetry_collector" {
}
module "argocd" {
count = var.create_eks && var.argocd_enable ? 1 : 0
source = "./kubernetes-addons/argocd"
argocd_helm_chart = var.argocd_helm_chart
count = var.create_eks && var.argocd_enable ? 1 : 0
source = "./kubernetes-addons/argocd"
argocd_helm_chart = var.argocd_helm_chart
argocd_applications = var.argocd_applications
depends_on = [module.aws_eks]
}
locals {
default_argocd_helm_app = {
default_argocd_helm_chart = {
name = "argo-cd"
chart = "argo-cd"
repository = "https://argoproj.github.io/argo-helm"
version = "3.26.3"
namespace = "argocd"
namespace = "argocd-infra"
timeout = "1200"
create_namespace = true
values = local.default_argocd_helm_values
......@@ -40,8 +40,9 @@ locals {
description = "The argocd HelmChart Ingress Controller deployment configuration"
postrender = ""
}
argocd_helm_app = merge(
local.default_argocd_helm_app,
local.default_argocd_helm_chart,
var.argocd_helm_chart
)
default_argocd_helm_values = [templatefile("${path.module}/argocd-values.yaml", {})]
......
......@@ -73,5 +73,42 @@ resource "helm_release" "argocd" {
value = each_item.value.value
}
}
}
# ---------------------------------------------------------------------------------------------------------------------
# ArgoCD App of Apps Bootstrapping
# ---------------------------------------------------------------------------------------------------------------------
resource "kubernetes_manifest" "argocd_application" {
for_each = var.argocd_applications
manifest = {
apiVersion: "argoproj.io/v1alpha1"
kind: "Application"
metadata: {
name: each.key
namespace: each.value.namespace
}
spec: {
destination: {
namespace: each.value.namespace
server: each.value.destination
}
project: each.value.project
source: {
helm: {
values: yamlencode(each.value.values)
}
path: each.value.repo_path
repoURL: each.value.repo_url
targetRevision: each.value.target_revision
}
syncPolicy: {
automated: {
prune: true
}
}
}
}
depends_on = [helm_release.argocd]
}
......@@ -20,3 +20,8 @@ variable "argocd_helm_chart" {
type = any
default = {}
}
variable "argocd_applications" {
type = any
default = {}
}
\ No newline at end of file
......@@ -371,3 +371,8 @@ variable "argocd_helm_chart" {
default = {}
description = "ARGO CD Kubernetes Addon Configuration"
}
variable "argocd_applications" {
type = any
default = {}
description = "ARGO CD Applications used to bootstrap the cluster."
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment