From a88e99f6812527d75b676b8f39661486d70f2dcf Mon Sep 17 00:00:00 2001 From: Carlos Santana Date: Tue, 29 Aug 2023 00:06:40 -0400 Subject: [PATCH] make gitops repo and branch as variables Signed-off-by: Carlos Santana --- .../aws-secrets-manager/bootstrap/addons.yaml | 8 ++--- .../examples/eks/aws-secrets-manager/main.tf | 13 ++++++- .../eks/aws-secrets-manager/outputs.tf | 13 ++++++- .../eks/aws-secrets-manager/variables.tf | 12 +++++++ .../eks/complete/bootstrap/addons.yaml | 10 +++--- .../terraform/examples/eks/complete/main.tf | 13 ++++++- .../examples/eks/complete/variables.tf | 12 +++++++ .../eks/crossplane/bootstrap/addons.yaml | 10 +++--- .../terraform/examples/eks/crossplane/main.tf | 36 +++++++++++++------ .../examples/eks/crossplane/variables.tf | 12 +++++++ .../external-secrets/bootstrap/addons.yaml | 8 ++--- .../examples/eks/external-secrets/main.tf | 13 ++++++- .../eks/external-secrets/variables.tf | 12 +++++++ .../eks/hello-world/bootstrap/addons.yaml | 8 ++--- .../examples/eks/hello-world/main.tf | 13 ++++++- .../examples/eks/hello-world/variables.tf | 12 +++++++ .../eks/ingress-alb/bootstrap/addons.yaml | 10 +++--- .../examples/eks/ingress-alb/main.tf | 13 ++++++- .../examples/eks/ingress-alb/variables.tf | 12 +++++++ .../distributed/bootstrap/addons.yaml | 10 +++--- .../eks/multi-cluster/distributed/main.tf | 13 ++++++- .../multi-cluster/distributed/variables.tf | 12 +++++++ .../hub/bootstrap/addons.yaml | 10 +++--- .../hub-spoke-shared/hub/main.tf | 13 ++++++- .../hub-spoke-shared/hub/variables.tf | 12 +++++++ .../hub-spoke-shared/spokes/main.tf | 7 ++++ .../hub-spoke-shared/spokes/variables.tf | 12 +++++++ .../hub-spoke/hub/bootstrap/addons.yaml | 10 +++--- .../eks/multi-cluster/hub-spoke/hub/main.tf | 13 ++++++- .../multi-cluster/hub-spoke/hub/variables.tf | 12 +++++++ .../multi-cluster/hub-spoke/spokes/main.tf | 7 ++++ .../multi-cluster/hub-spoke/spokes/outputs.tf | 8 ----- .../hub-spoke/spokes/variables.tf | 12 +++++++ .../modules/gitops-bridge-bootstrap/main.tf | 2 +- 34 files changed, 323 insertions(+), 70 deletions(-) create mode 100644 argocd/iac/terraform/examples/eks/crossplane/variables.tf diff --git a/argocd/iac/terraform/examples/eks/aws-secrets-manager/bootstrap/addons.yaml b/argocd/iac/terraform/examples/eks/aws-secrets-manager/bootstrap/addons.yaml index 8c714466..61216a94 100644 --- a/argocd/iac/terraform/examples/eks/aws-secrets-manager/bootstrap/addons.yaml +++ b/argocd/iac/terraform/examples/eks/aws-secrets-manager/bootstrap/addons.yaml @@ -9,11 +9,11 @@ spec: namespace: 'argocd' project: default source: - path: bootstrap/control-plane/addons - repoURL: https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template - targetRevision: HEAD + path: ${path} + repoURL: ${repoURL} + targetRevision: ${targetRevision} directory: recurse: true exclude: exclude/* syncPolicy: - automated: {} \ No newline at end of file + automated: {} diff --git a/argocd/iac/terraform/examples/eks/aws-secrets-manager/main.tf b/argocd/iac/terraform/examples/eks/aws-secrets-manager/main.tf index a7b30737..1a1277e2 100644 --- a/argocd/iac/terraform/examples/eks/aws-secrets-manager/main.tf +++ b/argocd/iac/terraform/examples/eks/aws-secrets-manager/main.tf @@ -49,6 +49,9 @@ locals { environment = "dev" region = "us-west-2" cluster_version = "1.27" + gitops_url = var.gitops_url + gitops_revision = var.gitops_revision + gitops_path = var.gitops_path aws_addons = { enable_cert_manager = true @@ -93,11 +96,19 @@ locals { aws_region = local.region aws_account_id = data.aws_caller_identity.current.account_id aws_vpc_id = module.vpc.vpc_id + }, + { + gitops_bridge_repo_url = local.gitops_url + gitops_bridge_repo_revision = local.gitops_revision } ) argocd_bootstrap_app_of_apps = { - addons = file("${path.module}/bootstrap/addons.yaml") + addons = templatefile("${path.module}/bootstrap/addons.yaml", { + repoURL = local.gitops_url + targetRevision = local.gitops_revision + path = local.gitops_path + }) workloads = file("${path.module}/bootstrap/workloads.yaml") } diff --git a/argocd/iac/terraform/examples/eks/aws-secrets-manager/outputs.tf b/argocd/iac/terraform/examples/eks/aws-secrets-manager/outputs.tf index 0803d61d..f2d1bb13 100644 --- a/argocd/iac/terraform/examples/eks/aws-secrets-manager/outputs.tf +++ b/argocd/iac/terraform/examples/eks/aws-secrets-manager/outputs.tf @@ -15,8 +15,19 @@ output "configure_argocd" { kubectl config set-context --current --namespace argocd argocd login --port-forward --username admin --password $(argocd admin initial-password | head -1) echo "ArgoCD Username: admin" - echo "ArgoCD Password: $(aws secretsmanager get-secret-value --secret-id argocd)" + echo "ArgoCD Password: $(kubectl get secrets argocd-initial-admin-secret -n argocd --template="{{index .data.password | base64decode}}")" echo Port Forward: http://localhost:8080 kubectl port-forward -n argocd svc/argo-cd-argocd-server 8080:80 EOT } + +output "access_argocd" { + description = "ArgoCD Access" + value = <<-EOT + export KUBECONFIG="/tmp/${module.eks.cluster_name}" + aws eks --region ${local.region} update-kubeconfig --name ${module.eks.cluster_name} + echo "ArgoCD URL: https://$(kubectl get svc -n argocd argo-cd-argocd-server -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')" + echo "ArgoCD Username: admin" + echo "ArgoCD Password: $(aws secretsmanager get-secret-value --secret-id argocd --output json | jq -r .SecretString)" + EOT +} diff --git a/argocd/iac/terraform/examples/eks/aws-secrets-manager/variables.tf b/argocd/iac/terraform/examples/eks/aws-secrets-manager/variables.tf index e69de29b..dbd72d91 100644 --- a/argocd/iac/terraform/examples/eks/aws-secrets-manager/variables.tf +++ b/argocd/iac/terraform/examples/eks/aws-secrets-manager/variables.tf @@ -0,0 +1,12 @@ +variable "gitops_url" { + description = "Git repository contains for addons" + default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template" +} +variable "gitops_revision" { + description = "Git repository revision/branch/ref for addons" + default = "HEAD" +} +variable "gitops_path" { + description = "Git repository path for addons" + default = "bootstrap/control-plane/addons" +} diff --git a/argocd/iac/terraform/examples/eks/complete/bootstrap/addons.yaml b/argocd/iac/terraform/examples/eks/complete/bootstrap/addons.yaml index 311983e6..61216a94 100644 --- a/argocd/iac/terraform/examples/eks/complete/bootstrap/addons.yaml +++ b/argocd/iac/terraform/examples/eks/complete/bootstrap/addons.yaml @@ -1,7 +1,7 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: bootstrap-control-plane + name: bootstrap-addons namespace: 'argocd' spec: destination: @@ -9,11 +9,11 @@ spec: namespace: 'argocd' project: default source: - path: bootstrap/control-plane - repoURL: https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template - targetRevision: HEAD + path: ${path} + repoURL: ${repoURL} + targetRevision: ${targetRevision} directory: recurse: true exclude: exclude/* syncPolicy: - automated: {} \ No newline at end of file + automated: {} diff --git a/argocd/iac/terraform/examples/eks/complete/main.tf b/argocd/iac/terraform/examples/eks/complete/main.tf index 1ebbc70f..741260c2 100644 --- a/argocd/iac/terraform/examples/eks/complete/main.tf +++ b/argocd/iac/terraform/examples/eks/complete/main.tf @@ -47,6 +47,9 @@ locals { environment = "dev" region = "us-west-2" cluster_version = "1.27" + gitops_url = var.gitops_url + gitops_revision = var.gitops_revision + gitops_path = var.gitops_path aws_addons = { enable_cert_manager = true @@ -92,13 +95,21 @@ locals { aws_account_id = data.aws_caller_identity.current.account_id aws_vpc_id = module.vpc.vpc_id }, + { + gitops_bridge_repo_url = local.gitops_url + gitops_bridge_repo_revision = local.gitops_revision + }, try(local.aws_addons.enable_velero, false) ? { velero_backup_s3_bucket_prefix = try(local.velero_backup_s3_bucket_prefix,"") velero_backup_s3_bucket_name = try(local.velero_backup_s3_bucket_name,"") } : {} # Required when enabling addon velero ) argocd_bootstrap_app_of_apps = { - addons = file("${path.module}/bootstrap/addons.yaml") + addons = templatefile("${path.module}/bootstrap/addons.yaml", { + repoURL = local.gitops_url + targetRevision = local.gitops_revision + path = local.gitops_path + }) workloads = file("${path.module}/bootstrap/workloads.yaml") } diff --git a/argocd/iac/terraform/examples/eks/complete/variables.tf b/argocd/iac/terraform/examples/eks/complete/variables.tf index e69de29b..dbd72d91 100644 --- a/argocd/iac/terraform/examples/eks/complete/variables.tf +++ b/argocd/iac/terraform/examples/eks/complete/variables.tf @@ -0,0 +1,12 @@ +variable "gitops_url" { + description = "Git repository contains for addons" + default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template" +} +variable "gitops_revision" { + description = "Git repository revision/branch/ref for addons" + default = "HEAD" +} +variable "gitops_path" { + description = "Git repository path for addons" + default = "bootstrap/control-plane/addons" +} diff --git a/argocd/iac/terraform/examples/eks/crossplane/bootstrap/addons.yaml b/argocd/iac/terraform/examples/eks/crossplane/bootstrap/addons.yaml index 311983e6..61216a94 100644 --- a/argocd/iac/terraform/examples/eks/crossplane/bootstrap/addons.yaml +++ b/argocd/iac/terraform/examples/eks/crossplane/bootstrap/addons.yaml @@ -1,7 +1,7 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: bootstrap-control-plane + name: bootstrap-addons namespace: 'argocd' spec: destination: @@ -9,11 +9,11 @@ spec: namespace: 'argocd' project: default source: - path: bootstrap/control-plane - repoURL: https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template - targetRevision: HEAD + path: ${path} + repoURL: ${repoURL} + targetRevision: ${targetRevision} directory: recurse: true exclude: exclude/* syncPolicy: - automated: {} \ No newline at end of file + automated: {} diff --git a/argocd/iac/terraform/examples/eks/crossplane/main.tf b/argocd/iac/terraform/examples/eks/crossplane/main.tf index 1d7a55dd..1d962e3d 100644 --- a/argocd/iac/terraform/examples/eks/crossplane/main.tf +++ b/argocd/iac/terraform/examples/eks/crossplane/main.tf @@ -1,9 +1,9 @@ provider "aws" { region = local.region } +data "aws_caller_identity" "current" {} data "aws_availability_zones" "available" {} - provider "helm" { kubernetes { host = module.eks.cluster_endpoint @@ -43,9 +43,13 @@ provider "kubernetes" { } locals { - name = "ex-${replace(basename(path.cwd), "_", "-")}" - environment = "control-plane" - region = "us-west-2" + name = "ex-${replace(basename(path.cwd), "_", "-")}" + environment = "control-plane" + region = "us-west-2" + cluster_version = "1.27" + gitops_url = var.gitops_url + gitops_revision = var.gitops_revision + gitops_path = var.gitops_path aws_addons = { enable_cert_manager = true @@ -87,20 +91,32 @@ locals { #enable_vpa = true #enable_foo = true # you can add any addon here, make sure to update the gitops repo with the corresponding application set } - addons = merge(local.aws_addons, local.oss_addons) + addons = merge(local.aws_addons, local.oss_addons, { kubernetes_version = local.cluster_version }) - addons_metadata = merge({ - aws_vpc_id = module.vpc.vpc_id # Only required when enabling the aws_gateway_api_controller addon - }, + addons_metadata = merge( module.eks_blueprints_addons.gitops_metadata, + { + aws_cluster_name = module.eks.cluster_name + aws_region = local.region + aws_account_id = data.aws_caller_identity.current.account_id + aws_vpc_id = module.vpc.vpc_id + }, { aws_crossplane_iam_role_arn = module.crossplane_irsa_aws.iam_role_arn aws_upbound_crossplane_iam_role_arn = module.crossplane_irsa_aws.iam_role_arn + }, + { + gitops_bridge_repo_url = local.gitops_url + gitops_bridge_repo_revision = local.gitops_revision } ) argocd_bootstrap_app_of_apps = { - addons = file("${path.module}/bootstrap/addons.yaml") + addons = templatefile("${path.module}/bootstrap/addons.yaml", { + repoURL = local.gitops_url + targetRevision = local.gitops_revision + path = local.gitops_path + }) workloads = file("${path.module}/bootstrap/workloads.yaml") } @@ -209,7 +225,7 @@ module "eks" { version = "~> 19.13" cluster_name = local.name - cluster_version = "1.27" + cluster_version = local.cluster_version cluster_endpoint_public_access = true diff --git a/argocd/iac/terraform/examples/eks/crossplane/variables.tf b/argocd/iac/terraform/examples/eks/crossplane/variables.tf new file mode 100644 index 00000000..dbd72d91 --- /dev/null +++ b/argocd/iac/terraform/examples/eks/crossplane/variables.tf @@ -0,0 +1,12 @@ +variable "gitops_url" { + description = "Git repository contains for addons" + default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template" +} +variable "gitops_revision" { + description = "Git repository revision/branch/ref for addons" + default = "HEAD" +} +variable "gitops_path" { + description = "Git repository path for addons" + default = "bootstrap/control-plane/addons" +} diff --git a/argocd/iac/terraform/examples/eks/external-secrets/bootstrap/addons.yaml b/argocd/iac/terraform/examples/eks/external-secrets/bootstrap/addons.yaml index 9dc2b176..61216a94 100644 --- a/argocd/iac/terraform/examples/eks/external-secrets/bootstrap/addons.yaml +++ b/argocd/iac/terraform/examples/eks/external-secrets/bootstrap/addons.yaml @@ -9,11 +9,11 @@ spec: namespace: 'argocd' project: default source: - path: bootstrap/control-plane - repoURL: https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template - targetRevision: HEAD + path: ${path} + repoURL: ${repoURL} + targetRevision: ${targetRevision} directory: recurse: true exclude: exclude/* syncPolicy: - automated: {} \ No newline at end of file + automated: {} diff --git a/argocd/iac/terraform/examples/eks/external-secrets/main.tf b/argocd/iac/terraform/examples/eks/external-secrets/main.tf index 4e2a6d10..18df2e7e 100644 --- a/argocd/iac/terraform/examples/eks/external-secrets/main.tf +++ b/argocd/iac/terraform/examples/eks/external-secrets/main.tf @@ -47,6 +47,9 @@ locals { environment = "dev" region = "us-west-2" cluster_version = "1.27" + gitops_url = var.gitops_url + gitops_revision = var.gitops_revision + gitops_path = var.gitops_path aws_secret_manager_secret_name = "argocd-ssh-key" git_private_ssh_key = "~/.ssh/id_rsa" # Update with the git ssh key to be used by ArgoCD @@ -94,11 +97,19 @@ locals { aws_region = local.region aws_account_id = data.aws_caller_identity.current.account_id aws_vpc_id = module.vpc.vpc_id + }, + { + gitops_bridge_repo_url = local.gitops_url + gitops_bridge_repo_revision = local.gitops_revision } ) argocd_bootstrap_app_of_apps = { - addons = file("${path.module}/bootstrap/addons.yaml") + addons = templatefile("${path.module}/bootstrap/addons.yaml", { + repoURL = local.gitops_url + targetRevision = local.gitops_revision + path = local.gitops_path + }) workloads = file("${path.module}/bootstrap/workloads.yaml") } diff --git a/argocd/iac/terraform/examples/eks/external-secrets/variables.tf b/argocd/iac/terraform/examples/eks/external-secrets/variables.tf index e69de29b..dbd72d91 100644 --- a/argocd/iac/terraform/examples/eks/external-secrets/variables.tf +++ b/argocd/iac/terraform/examples/eks/external-secrets/variables.tf @@ -0,0 +1,12 @@ +variable "gitops_url" { + description = "Git repository contains for addons" + default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template" +} +variable "gitops_revision" { + description = "Git repository revision/branch/ref for addons" + default = "HEAD" +} +variable "gitops_path" { + description = "Git repository path for addons" + default = "bootstrap/control-plane/addons" +} diff --git a/argocd/iac/terraform/examples/eks/hello-world/bootstrap/addons.yaml b/argocd/iac/terraform/examples/eks/hello-world/bootstrap/addons.yaml index 8c714466..61216a94 100644 --- a/argocd/iac/terraform/examples/eks/hello-world/bootstrap/addons.yaml +++ b/argocd/iac/terraform/examples/eks/hello-world/bootstrap/addons.yaml @@ -9,11 +9,11 @@ spec: namespace: 'argocd' project: default source: - path: bootstrap/control-plane/addons - repoURL: https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template - targetRevision: HEAD + path: ${path} + repoURL: ${repoURL} + targetRevision: ${targetRevision} directory: recurse: true exclude: exclude/* syncPolicy: - automated: {} \ No newline at end of file + automated: {} diff --git a/argocd/iac/terraform/examples/eks/hello-world/main.tf b/argocd/iac/terraform/examples/eks/hello-world/main.tf index e41680c0..a8e6e00f 100644 --- a/argocd/iac/terraform/examples/eks/hello-world/main.tf +++ b/argocd/iac/terraform/examples/eks/hello-world/main.tf @@ -47,6 +47,9 @@ locals { environment = "dev" region = "us-west-2" cluster_version = "1.27" + gitops_url = var.gitops_url + gitops_revision = var.gitops_revision + gitops_path = var.gitops_path aws_addons = { enable_cert_manager = true @@ -91,11 +94,19 @@ locals { aws_region = local.region aws_account_id = data.aws_caller_identity.current.account_id aws_vpc_id = module.vpc.vpc_id + }, + { + gitops_bridge_repo_url = local.gitops_url + gitops_bridge_repo_revision = local.gitops_revision } ) argocd_bootstrap_app_of_apps = { - addons = file("${path.module}/bootstrap/addons.yaml") + addons = templatefile("${path.module}/bootstrap/addons.yaml", { + repoURL = local.gitops_url + targetRevision = local.gitops_revision + path = local.gitops_path + }) workloads = file("${path.module}/bootstrap/workloads.yaml") } diff --git a/argocd/iac/terraform/examples/eks/hello-world/variables.tf b/argocd/iac/terraform/examples/eks/hello-world/variables.tf index e69de29b..dbd72d91 100644 --- a/argocd/iac/terraform/examples/eks/hello-world/variables.tf +++ b/argocd/iac/terraform/examples/eks/hello-world/variables.tf @@ -0,0 +1,12 @@ +variable "gitops_url" { + description = "Git repository contains for addons" + default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template" +} +variable "gitops_revision" { + description = "Git repository revision/branch/ref for addons" + default = "HEAD" +} +variable "gitops_path" { + description = "Git repository path for addons" + default = "bootstrap/control-plane/addons" +} diff --git a/argocd/iac/terraform/examples/eks/ingress-alb/bootstrap/addons.yaml b/argocd/iac/terraform/examples/eks/ingress-alb/bootstrap/addons.yaml index 311983e6..61216a94 100644 --- a/argocd/iac/terraform/examples/eks/ingress-alb/bootstrap/addons.yaml +++ b/argocd/iac/terraform/examples/eks/ingress-alb/bootstrap/addons.yaml @@ -1,7 +1,7 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: bootstrap-control-plane + name: bootstrap-addons namespace: 'argocd' spec: destination: @@ -9,11 +9,11 @@ spec: namespace: 'argocd' project: default source: - path: bootstrap/control-plane - repoURL: https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template - targetRevision: HEAD + path: ${path} + repoURL: ${repoURL} + targetRevision: ${targetRevision} directory: recurse: true exclude: exclude/* syncPolicy: - automated: {} \ No newline at end of file + automated: {} diff --git a/argocd/iac/terraform/examples/eks/ingress-alb/main.tf b/argocd/iac/terraform/examples/eks/ingress-alb/main.tf index d8a062e2..6dd52c33 100644 --- a/argocd/iac/terraform/examples/eks/ingress-alb/main.tf +++ b/argocd/iac/terraform/examples/eks/ingress-alb/main.tf @@ -47,6 +47,9 @@ locals { environment = "dev" region = "us-west-2" cluster_version = "1.27" + gitops_url = var.gitops_url + gitops_revision = var.gitops_revision + gitops_path = var.gitops_path enable_ingress = true domain_private_zone = false @@ -109,11 +112,19 @@ locals { external_dns_domain_filters = "[${local.domain_name}]" argocd_iam_role_arn = "" argocd_namespace = "argocd" + }, + { + gitops_bridge_repo_url = local.gitops_url + gitops_bridge_repo_revision = local.gitops_revision } ) argocd_bootstrap_app_of_apps = { - addons = file("${path.module}/bootstrap/addons.yaml") + addons = templatefile("${path.module}/bootstrap/addons.yaml", { + repoURL = local.gitops_url + targetRevision = local.gitops_revision + path = local.gitops_path + }) workloads = file("${path.module}/bootstrap/workloads.yaml") } diff --git a/argocd/iac/terraform/examples/eks/ingress-alb/variables.tf b/argocd/iac/terraform/examples/eks/ingress-alb/variables.tf index 61b720c5..6bcc8fc3 100644 --- a/argocd/iac/terraform/examples/eks/ingress-alb/variables.tf +++ b/argocd/iac/terraform/examples/eks/ingress-alb/variables.tf @@ -1,3 +1,15 @@ variable "domain_name" { description = "Route 53 domain name" } +variable "gitops_url" { + description = "Git repository contains for addons" + default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template" +} +variable "gitops_revision" { + description = "Git repository revision/branch/ref for addons" + default = "HEAD" +} +variable "gitops_path" { + description = "Git repository path for addons" + default = "bootstrap/control-plane/addons" +} diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/distributed/bootstrap/addons.yaml b/argocd/iac/terraform/examples/eks/multi-cluster/distributed/bootstrap/addons.yaml index 311983e6..61216a94 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/distributed/bootstrap/addons.yaml +++ b/argocd/iac/terraform/examples/eks/multi-cluster/distributed/bootstrap/addons.yaml @@ -1,7 +1,7 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: bootstrap-control-plane + name: bootstrap-addons namespace: 'argocd' spec: destination: @@ -9,11 +9,11 @@ spec: namespace: 'argocd' project: default source: - path: bootstrap/control-plane - repoURL: https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template - targetRevision: HEAD + path: ${path} + repoURL: ${repoURL} + targetRevision: ${targetRevision} directory: recurse: true exclude: exclude/* syncPolicy: - automated: {} \ No newline at end of file + automated: {} diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/distributed/main.tf b/argocd/iac/terraform/examples/eks/multi-cluster/distributed/main.tf index 40ad6427..1e67fa6c 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/distributed/main.tf +++ b/argocd/iac/terraform/examples/eks/multi-cluster/distributed/main.tf @@ -48,6 +48,9 @@ locals { region = "us-west-2" cluster_version = var.kubernetes_version vpc_cidr = var.vpc_cidr + gitops_url = var.gitops_url + gitops_revision = var.gitops_revision + gitops_path = var.gitops_path aws_addons = { enable_cert_manager = true @@ -92,11 +95,19 @@ locals { aws_region = local.region aws_account_id = data.aws_caller_identity.current.account_id aws_vpc_id = module.vpc.vpc_id + }, + { + gitops_bridge_repo_url = local.gitops_url + gitops_bridge_repo_revision = local.gitops_revision } ) argocd_bootstrap_app_of_apps = { - addons = file("${path.module}/bootstrap/addons.yaml") + addons = templatefile("${path.module}/bootstrap/addons.yaml", { + repoURL = local.gitops_url + targetRevision = local.gitops_revision + path = local.gitops_path + }) workloads = templatefile("${path.module}/bootstrap/workloads.yaml", { environment = local.environment diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/distributed/variables.tf b/argocd/iac/terraform/examples/eks/multi-cluster/distributed/variables.tf index 5c055933..656fb109 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/distributed/variables.tf +++ b/argocd/iac/terraform/examples/eks/multi-cluster/distributed/variables.tf @@ -4,3 +4,15 @@ variable "vpc_cidr" { variable "kubernetes_version" { description = "EKS version" } +variable "gitops_url" { + description = "Git repository contains for addons" + default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template" +} +variable "gitops_revision" { + description = "Git repository revision/branch/ref for addons" + default = "HEAD" +} +variable "gitops_path" { + description = "Git repository path for addons" + default = "bootstrap/control-plane/addons" +} diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/hub/bootstrap/addons.yaml b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/hub/bootstrap/addons.yaml index 311983e6..61216a94 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/hub/bootstrap/addons.yaml +++ b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/hub/bootstrap/addons.yaml @@ -1,7 +1,7 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: bootstrap-control-plane + name: bootstrap-addons namespace: 'argocd' spec: destination: @@ -9,11 +9,11 @@ spec: namespace: 'argocd' project: default source: - path: bootstrap/control-plane - repoURL: https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template - targetRevision: HEAD + path: ${path} + repoURL: ${repoURL} + targetRevision: ${targetRevision} directory: recurse: true exclude: exclude/* syncPolicy: - automated: {} \ No newline at end of file + automated: {} diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/hub/main.tf b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/hub/main.tf index 17549c4e..cd5add2a 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/hub/main.tf +++ b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/hub/main.tf @@ -48,6 +48,9 @@ locals { region = "us-west-2" cluster_version = var.kubernetes_version vpc_cidr = var.vpc_cidr + gitops_url = var.gitops_url + gitops_revision = var.gitops_revision + gitops_path = var.gitops_path aws_addons = { enable_cert_manager = true @@ -98,11 +101,19 @@ locals { { argocd_iam_role_arn = module.argocd_irsa.iam_role_arn, argocd_namespace = "argocd" + }, + { + gitops_bridge_repo_url = local.gitops_url + gitops_bridge_repo_revision = local.gitops_revision } ) argocd_bootstrap_app_of_apps = { - addons = file("${path.module}/bootstrap/addons.yaml") + addons = templatefile("${path.module}/bootstrap/addons.yaml", { + repoURL = local.gitops_url + targetRevision = local.gitops_revision + path = local.gitops_path + }) } azs = slice(data.aws_availability_zones.available.names, 0, 3) diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/hub/variables.tf b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/hub/variables.tf index 43dc82f1..34ad6103 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/hub/variables.tf +++ b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/hub/variables.tf @@ -8,3 +8,15 @@ variable "kubernetes_version" { default = "1.27" type = string } +variable "gitops_url" { + description = "Git repository contains for addons" + default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template" +} +variable "gitops_revision" { + description = "Git repository revision/branch/ref for addons" + default = "HEAD" +} +variable "gitops_path" { + description = "Git repository path for addons" + default = "bootstrap/control-plane/addons" +} diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/spokes/main.tf b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/spokes/main.tf index cfbfb779..f56b51a1 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/spokes/main.tf +++ b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/spokes/main.tf @@ -93,6 +93,9 @@ locals { region = "us-west-2" cluster_version = var.kubernetes_version vpc_cidr = var.vpc_cidr + gitops_url = var.gitops_url + gitops_revision = var.gitops_revision + gitops_path = var.gitops_path aws_addons = { enable_cert_manager = true @@ -137,6 +140,10 @@ locals { aws_region = local.region aws_account_id = data.aws_caller_identity.current.account_id aws_vpc_id = module.vpc.vpc_id + }, + { + gitops_bridge_repo_url = local.gitops_url + gitops_bridge_repo_revision = local.gitops_revision } ) diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/spokes/variables.tf b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/spokes/variables.tf index 5ccf6f3d..63377f88 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/spokes/variables.tf +++ b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke-shared/spokes/variables.tf @@ -6,3 +6,15 @@ variable "kubernetes_version" { description = "EKS version" type = string } +variable "gitops_url" { + description = "Git repository contains for addons" + default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template" +} +variable "gitops_revision" { + description = "Git repository revision/branch/ref for addons" + default = "HEAD" +} +variable "gitops_path" { + description = "Git repository path for addons" + default = "bootstrap/control-plane/addons" +} diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/hub/bootstrap/addons.yaml b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/hub/bootstrap/addons.yaml index 311983e6..61216a94 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/hub/bootstrap/addons.yaml +++ b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/hub/bootstrap/addons.yaml @@ -1,7 +1,7 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: bootstrap-control-plane + name: bootstrap-addons namespace: 'argocd' spec: destination: @@ -9,11 +9,11 @@ spec: namespace: 'argocd' project: default source: - path: bootstrap/control-plane - repoURL: https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template - targetRevision: HEAD + path: ${path} + repoURL: ${repoURL} + targetRevision: ${targetRevision} directory: recurse: true exclude: exclude/* syncPolicy: - automated: {} \ No newline at end of file + automated: {} diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/hub/main.tf b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/hub/main.tf index 4fa96224..21369022 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/hub/main.tf +++ b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/hub/main.tf @@ -48,6 +48,9 @@ locals { region = "us-west-2" cluster_version = var.kubernetes_version vpc_cidr = var.vpc_cidr + gitops_url = var.gitops_url + gitops_revision = var.gitops_revision + gitops_path = var.gitops_path aws_addons = { enable_cert_manager = true @@ -98,11 +101,19 @@ locals { { argocd_iam_role_arn = module.argocd_irsa.iam_role_arn, argocd_namespace = "argocd" + }, + { + gitops_bridge_repo_url = local.gitops_url + gitops_bridge_repo_revision = local.gitops_revision } ) argocd_bootstrap_app_of_apps = { - addons = file("${path.module}/bootstrap/addons.yaml") + addons = templatefile("${path.module}/bootstrap/addons.yaml", { + repoURL = local.gitops_url + targetRevision = local.gitops_revision + path = local.gitops_path + }) } azs = slice(data.aws_availability_zones.available.names, 0, 3) diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/hub/variables.tf b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/hub/variables.tf index f1c598c5..5f658eab 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/hub/variables.tf +++ b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/hub/variables.tf @@ -6,3 +6,15 @@ variable "kubernetes_version" { description = "EKS version" default = "1.27" } +variable "gitops_url" { + description = "Git repository contains for addons" + default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template" +} +variable "gitops_revision" { + description = "Git repository revision/branch/ref for addons" + default = "HEAD" +} +variable "gitops_path" { + description = "Git repository path for addons" + default = "bootstrap/control-plane/addons" +} diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/spokes/main.tf b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/spokes/main.tf index 8940bc57..4f2e4c88 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/spokes/main.tf +++ b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/spokes/main.tf @@ -67,6 +67,9 @@ locals { region = "us-west-2" cluster_version = var.kubernetes_version vpc_cidr = var.vpc_cidr + gitops_url = var.gitops_url + gitops_revision = var.gitops_revision + gitops_path = var.gitops_path aws_addons = { enable_cert_manager = true @@ -112,6 +115,10 @@ locals { aws_region = local.region aws_account_id = data.aws_caller_identity.current.account_id aws_vpc_id = module.vpc.vpc_id + }, + { + gitops_bridge_repo_url = local.gitops_url + gitops_bridge_repo_revision = local.gitops_revision } ) diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/spokes/outputs.tf b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/spokes/outputs.tf index c7a4bc2e..974a0a9f 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/spokes/outputs.tf +++ b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/spokes/outputs.tf @@ -6,11 +6,3 @@ output "configure_kubectl" { EOT } - -output "configure_argocd" { - description = "Terminal Setup" - value = <<-EOT - export KUBECONFIG="/tmp/${module.eks.cluster_name}" - aws eks --region ${local.region} update-kubeconfig --name ${module.eks.cluster_name} - EOT -} diff --git a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/spokes/variables.tf b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/spokes/variables.tf index 5ccf6f3d..63377f88 100644 --- a/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/spokes/variables.tf +++ b/argocd/iac/terraform/examples/eks/multi-cluster/hub-spoke/spokes/variables.tf @@ -6,3 +6,15 @@ variable "kubernetes_version" { description = "EKS version" type = string } +variable "gitops_url" { + description = "Git repository contains for addons" + default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template" +} +variable "gitops_revision" { + description = "Git repository revision/branch/ref for addons" + default = "HEAD" +} +variable "gitops_path" { + description = "Git repository path for addons" + default = "bootstrap/control-plane/addons" +} diff --git a/argocd/iac/terraform/modules/gitops-bridge-bootstrap/main.tf b/argocd/iac/terraform/modules/gitops-bridge-bootstrap/main.tf index 6998a4fd..d51000df 100644 --- a/argocd/iac/terraform/modules/gitops-bridge-bootstrap/main.tf +++ b/argocd/iac/terraform/modules/gitops-bridge-bootstrap/main.tf @@ -11,7 +11,7 @@ resource "helm_release" "argocd" { namespace = try(var.argocd.namespace, "argocd") create_namespace = try(var.argocd.create_namespace, true) chart = try(var.argocd.chart,"argo-cd") - version = try(var.argocd.chart_version, "5.38.0") + version = try(var.argocd.chart_version, "5.43.4") repository = try(var.argocd.repository, "https://argoproj.github.io/argo-helm") values = try(var.argocd.values, [])