Skip to content

Commit 4babc5f

Browse files
authored
Merge pull request #2 from gitops-bridge-dev/url_metadata
make gitops repo and branch as variables
2 parents 0cd042a + a88e99f commit 4babc5f

File tree

34 files changed

+323
-70
lines changed

34 files changed

+323
-70
lines changed

argocd/iac/terraform/examples/eks/aws-secrets-manager/bootstrap/addons.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ spec:
99
namespace: 'argocd'
1010
project: default
1111
source:
12-
path: bootstrap/control-plane/addons
13-
repoURL: https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template
14-
targetRevision: HEAD
12+
path: ${path}
13+
repoURL: ${repoURL}
14+
targetRevision: ${targetRevision}
1515
directory:
1616
recurse: true
1717
exclude: exclude/*
1818
syncPolicy:
19-
automated: {}
19+
automated: {}

argocd/iac/terraform/examples/eks/aws-secrets-manager/main.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ locals {
4949
environment = "dev"
5050
region = "us-west-2"
5151
cluster_version = "1.27"
52+
gitops_url = var.gitops_url
53+
gitops_revision = var.gitops_revision
54+
gitops_path = var.gitops_path
5255

5356
aws_addons = {
5457
enable_cert_manager = true
@@ -93,11 +96,19 @@ locals {
9396
aws_region = local.region
9497
aws_account_id = data.aws_caller_identity.current.account_id
9598
aws_vpc_id = module.vpc.vpc_id
99+
},
100+
{
101+
gitops_bridge_repo_url = local.gitops_url
102+
gitops_bridge_repo_revision = local.gitops_revision
96103
}
97104
)
98105

99106
argocd_bootstrap_app_of_apps = {
100-
addons = file("${path.module}/bootstrap/addons.yaml")
107+
addons = templatefile("${path.module}/bootstrap/addons.yaml", {
108+
repoURL = local.gitops_url
109+
targetRevision = local.gitops_revision
110+
path = local.gitops_path
111+
})
101112
workloads = file("${path.module}/bootstrap/workloads.yaml")
102113
}
103114

argocd/iac/terraform/examples/eks/aws-secrets-manager/outputs.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,19 @@ output "configure_argocd" {
1515
kubectl config set-context --current --namespace argocd
1616
argocd login --port-forward --username admin --password $(argocd admin initial-password | head -1)
1717
echo "ArgoCD Username: admin"
18-
echo "ArgoCD Password: $(aws secretsmanager get-secret-value --secret-id argocd)"
18+
echo "ArgoCD Password: $(kubectl get secrets argocd-initial-admin-secret -n argocd --template="{{index .data.password | base64decode}}")"
1919
echo Port Forward: http://localhost:8080
2020
kubectl port-forward -n argocd svc/argo-cd-argocd-server 8080:80
2121
EOT
2222
}
23+
24+
output "access_argocd" {
25+
description = "ArgoCD Access"
26+
value = <<-EOT
27+
export KUBECONFIG="/tmp/${module.eks.cluster_name}"
28+
aws eks --region ${local.region} update-kubeconfig --name ${module.eks.cluster_name}
29+
echo "ArgoCD URL: https://$(kubectl get svc -n argocd argo-cd-argocd-server -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')"
30+
echo "ArgoCD Username: admin"
31+
echo "ArgoCD Password: $(aws secretsmanager get-secret-value --secret-id argocd --output json | jq -r .SecretString)"
32+
EOT
33+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
variable "gitops_url" {
2+
description = "Git repository contains for addons"
3+
default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template"
4+
}
5+
variable "gitops_revision" {
6+
description = "Git repository revision/branch/ref for addons"
7+
default = "HEAD"
8+
}
9+
variable "gitops_path" {
10+
description = "Git repository path for addons"
11+
default = "bootstrap/control-plane/addons"
12+
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
apiVersion: argoproj.io/v1alpha1
22
kind: Application
33
metadata:
4-
name: bootstrap-control-plane
4+
name: bootstrap-addons
55
namespace: 'argocd'
66
spec:
77
destination:
88
server: https://kubernetes.default.svc
99
namespace: 'argocd'
1010
project: default
1111
source:
12-
path: bootstrap/control-plane
13-
repoURL: https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template
14-
targetRevision: HEAD
12+
path: ${path}
13+
repoURL: ${repoURL}
14+
targetRevision: ${targetRevision}
1515
directory:
1616
recurse: true
1717
exclude: exclude/*
1818
syncPolicy:
19-
automated: {}
19+
automated: {}

argocd/iac/terraform/examples/eks/complete/main.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ locals {
4747
environment = "dev"
4848
region = "us-west-2"
4949
cluster_version = "1.27"
50+
gitops_url = var.gitops_url
51+
gitops_revision = var.gitops_revision
52+
gitops_path = var.gitops_path
5053

5154
aws_addons = {
5255
enable_cert_manager = true
@@ -92,13 +95,21 @@ locals {
9295
aws_account_id = data.aws_caller_identity.current.account_id
9396
aws_vpc_id = module.vpc.vpc_id
9497
},
98+
{
99+
gitops_bridge_repo_url = local.gitops_url
100+
gitops_bridge_repo_revision = local.gitops_revision
101+
},
95102
try(local.aws_addons.enable_velero, false) ? {
96103
velero_backup_s3_bucket_prefix = try(local.velero_backup_s3_bucket_prefix,"")
97104
velero_backup_s3_bucket_name = try(local.velero_backup_s3_bucket_name,"") } : {} # Required when enabling addon velero
98105
)
99106

100107
argocd_bootstrap_app_of_apps = {
101-
addons = file("${path.module}/bootstrap/addons.yaml")
108+
addons = templatefile("${path.module}/bootstrap/addons.yaml", {
109+
repoURL = local.gitops_url
110+
targetRevision = local.gitops_revision
111+
path = local.gitops_path
112+
})
102113
workloads = file("${path.module}/bootstrap/workloads.yaml")
103114
}
104115

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
variable "gitops_url" {
2+
description = "Git repository contains for addons"
3+
default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template"
4+
}
5+
variable "gitops_revision" {
6+
description = "Git repository revision/branch/ref for addons"
7+
default = "HEAD"
8+
}
9+
variable "gitops_path" {
10+
description = "Git repository path for addons"
11+
default = "bootstrap/control-plane/addons"
12+
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
apiVersion: argoproj.io/v1alpha1
22
kind: Application
33
metadata:
4-
name: bootstrap-control-plane
4+
name: bootstrap-addons
55
namespace: 'argocd'
66
spec:
77
destination:
88
server: https://kubernetes.default.svc
99
namespace: 'argocd'
1010
project: default
1111
source:
12-
path: bootstrap/control-plane
13-
repoURL: https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template
14-
targetRevision: HEAD
12+
path: ${path}
13+
repoURL: ${repoURL}
14+
targetRevision: ${targetRevision}
1515
directory:
1616
recurse: true
1717
exclude: exclude/*
1818
syncPolicy:
19-
automated: {}
19+
automated: {}

argocd/iac/terraform/examples/eks/crossplane/main.tf

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
provider "aws" {
22
region = local.region
33
}
4+
data "aws_caller_identity" "current" {}
45
data "aws_availability_zones" "available" {}
56

6-
77
provider "helm" {
88
kubernetes {
99
host = module.eks.cluster_endpoint
@@ -43,9 +43,13 @@ provider "kubernetes" {
4343
}
4444

4545
locals {
46-
name = "ex-${replace(basename(path.cwd), "_", "-")}"
47-
environment = "control-plane"
48-
region = "us-west-2"
46+
name = "ex-${replace(basename(path.cwd), "_", "-")}"
47+
environment = "control-plane"
48+
region = "us-west-2"
49+
cluster_version = "1.27"
50+
gitops_url = var.gitops_url
51+
gitops_revision = var.gitops_revision
52+
gitops_path = var.gitops_path
4953

5054
aws_addons = {
5155
enable_cert_manager = true
@@ -87,20 +91,32 @@ locals {
8791
#enable_vpa = true
8892
#enable_foo = true # you can add any addon here, make sure to update the gitops repo with the corresponding application set
8993
}
90-
addons = merge(local.aws_addons, local.oss_addons)
94+
addons = merge(local.aws_addons, local.oss_addons, { kubernetes_version = local.cluster_version })
9195

92-
addons_metadata = merge({
93-
aws_vpc_id = module.vpc.vpc_id # Only required when enabling the aws_gateway_api_controller addon
94-
},
96+
addons_metadata = merge(
9597
module.eks_blueprints_addons.gitops_metadata,
98+
{
99+
aws_cluster_name = module.eks.cluster_name
100+
aws_region = local.region
101+
aws_account_id = data.aws_caller_identity.current.account_id
102+
aws_vpc_id = module.vpc.vpc_id
103+
},
96104
{
97105
aws_crossplane_iam_role_arn = module.crossplane_irsa_aws.iam_role_arn
98106
aws_upbound_crossplane_iam_role_arn = module.crossplane_irsa_aws.iam_role_arn
107+
},
108+
{
109+
gitops_bridge_repo_url = local.gitops_url
110+
gitops_bridge_repo_revision = local.gitops_revision
99111
}
100112
)
101113

102114
argocd_bootstrap_app_of_apps = {
103-
addons = file("${path.module}/bootstrap/addons.yaml")
115+
addons = templatefile("${path.module}/bootstrap/addons.yaml", {
116+
repoURL = local.gitops_url
117+
targetRevision = local.gitops_revision
118+
path = local.gitops_path
119+
})
104120
workloads = file("${path.module}/bootstrap/workloads.yaml")
105121
}
106122

@@ -209,7 +225,7 @@ module "eks" {
209225
version = "~> 19.13"
210226

211227
cluster_name = local.name
212-
cluster_version = "1.27"
228+
cluster_version = local.cluster_version
213229
cluster_endpoint_public_access = true
214230

215231

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
variable "gitops_url" {
2+
description = "Git repository contains for addons"
3+
default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template"
4+
}
5+
variable "gitops_revision" {
6+
description = "Git repository revision/branch/ref for addons"
7+
default = "HEAD"
8+
}
9+
variable "gitops_path" {
10+
description = "Git repository path for addons"
11+
default = "bootstrap/control-plane/addons"
12+
}

0 commit comments

Comments
 (0)