From a6b01c6e12b84c417f77ca791c2fe0a1a47b513c Mon Sep 17 00:00:00 2001 From: Jonathan Kao Date: Sun, 3 Apr 2022 23:53:07 -0400 Subject: [PATCH 1/2] feat(argo-cd): add terraform --- terraform/helm/argo-cd.yaml | 20 ++++++++++++++++++++ terraform/modules/base_cluster/argo-cd.tf | 14 ++++++++++++++ terraform/modules/base_cluster/variables.tf | 6 ++++++ terraform/production-cluster.tf | 1 + 4 files changed, 41 insertions(+) create mode 100644 terraform/helm/argo-cd.yaml create mode 100644 terraform/modules/base_cluster/argo-cd.tf diff --git a/terraform/helm/argo-cd.yaml b/terraform/helm/argo-cd.yaml new file mode 100644 index 00000000..8dc97b26 --- /dev/null +++ b/terraform/helm/argo-cd.yaml @@ -0,0 +1,20 @@ +server: + additionalApplications: + - name: labs-kube-manifests + namespace: argo-cd + project: default + source: + repoURL: https://github.com/pennlabs/kube-manifests.git + targetRevision: HEAD + path: . + directory: + recurse: true + destination: + server: https://kubernetes.default.svc + namespace: default + syncPolicy: + syncOptions: + - CreateNamespace=true + automated: + prune: true + selfHeal: true diff --git a/terraform/modules/base_cluster/argo-cd.tf b/terraform/modules/base_cluster/argo-cd.tf new file mode 100644 index 00000000..af268188 --- /dev/null +++ b/terraform/modules/base_cluster/argo-cd.tf @@ -0,0 +1,14 @@ +resource "kubernetes_namespace" "argo-cd" { + metadata { + name = "argo-cd" + } +} + +resource "helm_release" "argo-cd" { + name = "argo-cd" + repository = "https://argoproj.github.io/argo-helm" + chart = "argo-cd" + version = "4.3.0" + namespace = kubernetes_namespace.argo-cd.metadata[0].name + values = var.argo-cd_values +} diff --git a/terraform/modules/base_cluster/variables.tf b/terraform/modules/base_cluster/variables.tf index 54d64773..40d93422 100644 --- a/terraform/modules/base_cluster/variables.tf +++ b/terraform/modules/base_cluster/variables.tf @@ -27,3 +27,9 @@ variable "datadog_values" { description = "Values to provide to the Datadog helm chart" type = list(string) } + +// Argo-cd values +variable "argo-cd_values" { + description = "Values to provide to the Argo-cd helm chart" + type = list(string) +} diff --git a/terraform/production-cluster.tf b/terraform/production-cluster.tf index 5932d8c3..84d3429e 100644 --- a/terraform/production-cluster.tf +++ b/terraform/production-cluster.tf @@ -40,6 +40,7 @@ module "production-cluster" { roleARN = module.iam-cert-manager.role-arn })] datadog_values = [file("helm/datadog.yaml")] + argo-cd_values = [file("helm/argo-cd.yaml")] } From e9a815f7dc847e14b555291df5dbc1f35dd3f0ff Mon Sep 17 00:00:00 2001 From: Jonathan Kao Date: Sat, 16 Apr 2022 10:43:40 -0400 Subject: [PATCH 2/2] feat: add kube-manifests tf bootstrap --- terraform/github.tf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/terraform/github.tf b/terraform/github.tf index 73652d82..b815c4a0 100644 --- a/terraform/github.tf +++ b/terraform/github.tf @@ -41,3 +41,9 @@ resource "github_actions_secret" "private_repos_aws_secret_key" { secret_name = "GH_AWS_SECRET_ACCESS_KEY" plaintext_value = aws_iam_access_key.gh-actions.secret } + +// Ensure a kube-manifests repository exists for Argo deployments +resource "github_repository" "kube_manifests_repository" { + name = "kube-manifests" + description = "Kubernetes manifests for our cluster" +}