Skip to content

Commit feb7183

Browse files
authored
Merge pull request #14 from gitops-bridge-dev/issue-11
refactor addons git info
2 parents b633c87 + 14793f1 commit feb7183

File tree

36 files changed

+669
-404
lines changed

36 files changed

+669
-404
lines changed

argocd/iac/terraform/examples/eks/aws-secrets-manager/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ terraform init
99
terraform apply
1010
```
1111

12-
Access Terraform output to configure `kubectl` and `argocd`
12+
Access Terraform output to configure `kubectl` and `argocd` (it includes argocd password)
1313
```shell
1414
terraform output
1515
```
1616

17+
To get the argocd `admin` password stored in AWS Secret Manager
18+
```shell
19+
aws secretsmanager get-secret-value --secret-id argocd --output json | jq -r .SecretString
20+
```
21+
1722
Destroy EKS Cluster
1823
```shell
1924
cd hub
Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1+
---
12
apiVersion: argoproj.io/v1alpha1
2-
kind: Application
3+
kind: ApplicationSet
34
metadata:
45
name: bootstrap-addons
5-
namespace: 'argocd'
6+
namespace: argocd
67
spec:
7-
destination:
8-
server: https://kubernetes.default.svc
9-
namespace: 'argocd'
10-
project: default
11-
source:
12-
path: ${path}
13-
repoURL: ${repoURL}
14-
targetRevision: ${targetRevision}
15-
directory:
16-
recurse: true
17-
exclude: exclude/*
188
syncPolicy:
19-
automated: {}
9+
preserveResourcesOnDeletion: true
10+
generators:
11+
- clusters:
12+
selector:
13+
matchExpressions:
14+
- key: akuity.io/argo-cd-cluster-name
15+
operator: NotIn
16+
values: [in-cluster]
17+
template:
18+
metadata:
19+
name: 'bootstrap-addons'
20+
spec:
21+
project: default
22+
source:
23+
repoURL: '{{metadata.annotations.addons_repo_url}}'
24+
path: '{{metadata.annotations.addons_repo_basepath}}{{metadata.annotations.addons_repo_path}}'
25+
targetRevision: '{{metadata.annotations.addons_repo_revision}}'
26+
directory:
27+
recurse: true
28+
exclude: exclude/*
29+
destination:
30+
namespace: 'argocd'
31+
name: '{{name}}'
32+
syncPolicy:
33+
automated: {}

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ provider "kubernetes" {
4545
}
4646

4747
locals {
48-
name = "ex-${replace(basename(path.cwd), "_", "-")}"
49-
environment = "dev"
50-
region = "us-west-2"
51-
cluster_version = "1.27"
52-
gitops_url = var.gitops_url
53-
gitops_revision = var.gitops_revision
54-
gitops_path = var.gitops_path
48+
name = "ex-${replace(basename(path.cwd), "_", "-")}"
49+
environment = "dev"
50+
region = "us-west-2"
51+
cluster_version = "1.27"
52+
gitops_addons_url = "${var.gitops_addons_org}/${var.gitops_addons_repo}"
53+
gitops_addons_basepath = var.gitops_addons_basepath
54+
gitops_addons_path = var.gitops_addons_path
55+
gitops_addons_revision = var.gitops_addons_revision
56+
5557

5658
aws_addons = {
5759
enable_cert_manager = true
@@ -98,17 +100,15 @@ locals {
98100
aws_vpc_id = module.vpc.vpc_id
99101
},
100102
{
101-
gitops_bridge_repo_url = local.gitops_url
102-
gitops_bridge_repo_revision = local.gitops_revision
103+
addons_repo_url = local.gitops_addons_url
104+
addons_repo_basepath = local.gitops_addons_basepath
105+
addons_repo_path = local.gitops_addons_path
106+
addons_repo_revision = local.gitops_addons_revision
103107
}
104108
)
105109

106110
argocd_bootstrap_app_of_apps = {
107-
addons = templatefile("${path.module}/bootstrap/addons.yaml", {
108-
repoURL = local.gitops_url
109-
targetRevision = local.gitops_revision
110-
path = local.gitops_path
111-
})
111+
addons = file("${path.module}/bootstrap/addons.yaml")
112112
workloads = file("${path.module}/bootstrap/workloads.yaml")
113113
}
114114

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ output "configure_argocd" {
1313
aws eks --region ${local.region} update-kubeconfig --name ${module.eks.cluster_name}
1414
export ARGOCD_OPTS="--port-forward --port-forward-namespace argocd --grpc-web"
1515
kubectl config set-context --current --namespace argocd
16-
argocd login --port-forward --username admin --password $(argocd admin initial-password | head -1)
16+
argocd login --port-forward --username admin --password $(aws secretsmanager get-secret-value --secret-id argocd --output json | jq -r .SecretString)
1717
echo "ArgoCD Username: admin"
18-
echo "ArgoCD Password: $(kubectl get secrets argocd-initial-admin-secret -n argocd --template="{{index .data.password | base64decode}}")"
18+
echo "ArgoCD Password: $(aws secretsmanager get-secret-value --secret-id argocd --output json | jq -r .SecretString)"
1919
echo Port Forward: http://localhost:8080
2020
kubectl port-forward -n argocd svc/argo-cd-argocd-server 8080:80
2121
EOT
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
variable "gitops_url" {
1+
variable "gitops_addons_org" {
2+
description = "Git repository org/user contains for addons"
3+
default = "https://github.com/gitops-bridge-dev"
4+
}
5+
variable "gitops_addons_repo" {
26
description = "Git repository contains for addons"
3-
default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template"
7+
default = "gitops-bridge-argocd-control-plane-template"
48
}
5-
variable "gitops_revision" {
6-
description = "Git repository revision/branch/ref for addons"
7-
default = "HEAD"
9+
variable "gitops_addons_basepath" {
10+
description = "Git repository base path for addons"
11+
default = ""
812
}
9-
variable "gitops_path" {
13+
variable "gitops_addons_path" {
1014
description = "Git repository path for addons"
1115
default = "bootstrap/control-plane/addons"
1216
}
17+
variable "gitops_addons_revision" {
18+
description = "Git repository revision/branch/ref for addons"
19+
default = "HEAD"
20+
}
Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1+
---
12
apiVersion: argoproj.io/v1alpha1
2-
kind: Application
3+
kind: ApplicationSet
34
metadata:
45
name: bootstrap-addons
5-
namespace: 'argocd'
6+
namespace: argocd
67
spec:
7-
destination:
8-
server: https://kubernetes.default.svc
9-
namespace: 'argocd'
10-
project: default
11-
source:
12-
path: ${path}
13-
repoURL: ${repoURL}
14-
targetRevision: ${targetRevision}
15-
directory:
16-
recurse: true
17-
exclude: exclude/*
188
syncPolicy:
19-
automated: {}
9+
preserveResourcesOnDeletion: true
10+
generators:
11+
- clusters:
12+
selector:
13+
matchExpressions:
14+
- key: akuity.io/argo-cd-cluster-name
15+
operator: NotIn
16+
values: [in-cluster]
17+
template:
18+
metadata:
19+
name: 'bootstrap-addons'
20+
spec:
21+
project: default
22+
source:
23+
repoURL: '{{metadata.annotations.addons_repo_url}}'
24+
path: '{{metadata.annotations.addons_repo_basepath}}{{metadata.annotations.addons_repo_path}}'
25+
targetRevision: '{{metadata.annotations.addons_repo_revision}}'
26+
directory:
27+
recurse: true
28+
exclude: exclude/*
29+
destination:
30+
namespace: 'argocd'
31+
name: '{{name}}'
32+
syncPolicy:
33+
automated: {}

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ 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
50+
gitops_addons_url = "${var.gitops_addons_org}/${var.gitops_addons_repo}"
51+
gitops_addons_basepath = var.gitops_addons_basepath
52+
gitops_addons_path = var.gitops_addons_path
53+
gitops_addons_revision = var.gitops_addons_revision
5354

5455
aws_addons = {
5556
enable_cert_manager = true
@@ -96,20 +97,18 @@ locals {
9697
aws_vpc_id = module.vpc.vpc_id
9798
},
9899
{
99-
gitops_bridge_repo_url = local.gitops_url
100-
gitops_bridge_repo_revision = local.gitops_revision
100+
addons_repo_url = local.gitops_addons_url
101+
addons_repo_basepath = local.gitops_addons_basepath
102+
addons_repo_path = local.gitops_addons_path
103+
addons_repo_revision = local.gitops_addons_revision
101104
},
102105
try(local.aws_addons.enable_velero, false) ? {
103106
velero_backup_s3_bucket_prefix = try(local.velero_backup_s3_bucket_prefix,"")
104107
velero_backup_s3_bucket_name = try(local.velero_backup_s3_bucket_name,"") } : {} # Required when enabling addon velero
105108
)
106109

107110
argocd_bootstrap_app_of_apps = {
108-
addons = templatefile("${path.module}/bootstrap/addons.yaml", {
109-
repoURL = local.gitops_url
110-
targetRevision = local.gitops_revision
111-
path = local.gitops_path
112-
})
111+
addons = file("${path.module}/bootstrap/addons.yaml")
113112
workloads = file("${path.module}/bootstrap/workloads.yaml")
114113
}
115114

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
variable "gitops_url" {
1+
variable "gitops_addons_org" {
2+
description = "Git repository org/user contains for addons"
3+
default = "https://github.com/gitops-bridge-dev"
4+
}
5+
variable "gitops_addons_repo" {
26
description = "Git repository contains for addons"
3-
default = "https://github.com/gitops-bridge-dev/gitops-bridge-argocd-control-plane-template"
7+
default = "gitops-bridge-argocd-control-plane-template"
48
}
5-
variable "gitops_revision" {
6-
description = "Git repository revision/branch/ref for addons"
7-
default = "HEAD"
9+
variable "gitops_addons_basepath" {
10+
description = "Git repository base path for addons"
11+
default = ""
812
}
9-
variable "gitops_path" {
13+
variable "gitops_addons_path" {
1014
description = "Git repository path for addons"
1115
default = "bootstrap/control-plane/addons"
1216
}
17+
variable "gitops_addons_revision" {
18+
description = "Git repository revision/branch/ref for addons"
19+
default = "HEAD"
20+
}
Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1+
---
12
apiVersion: argoproj.io/v1alpha1
2-
kind: Application
3+
kind: ApplicationSet
34
metadata:
45
name: bootstrap-addons
5-
namespace: 'argocd'
6+
namespace: argocd
67
spec:
7-
destination:
8-
server: https://kubernetes.default.svc
9-
namespace: 'argocd'
10-
project: default
11-
source:
12-
path: ${path}
13-
repoURL: ${repoURL}
14-
targetRevision: ${targetRevision}
15-
directory:
16-
recurse: true
17-
exclude: exclude/*
188
syncPolicy:
19-
automated: {}
9+
preserveResourcesOnDeletion: true
10+
generators:
11+
- clusters:
12+
selector:
13+
matchExpressions:
14+
- key: akuity.io/argo-cd-cluster-name
15+
operator: NotIn
16+
values: [in-cluster]
17+
template:
18+
metadata:
19+
name: 'bootstrap-addons'
20+
spec:
21+
project: default
22+
source:
23+
repoURL: '{{metadata.annotations.addons_repo_url}}'
24+
path: '{{metadata.annotations.addons_repo_basepath}}{{metadata.annotations.addons_repo_path}}'
25+
targetRevision: '{{metadata.annotations.addons_repo_revision}}'
26+
directory:
27+
recurse: true
28+
exclude: exclude/*
29+
destination:
30+
namespace: 'argocd'
31+
name: '{{name}}'
32+
syncPolicy:
33+
automated: {}

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

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ provider "kubernetes" {
4343
}
4444

4545
locals {
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
46+
name = "ex-${replace(basename(path.cwd), "_", "-")}"
47+
environment = "control-plane"
48+
region = "us-west-2"
49+
cluster_version = "1.27"
50+
gitops_addons_url = "${var.gitops_addons_org}/${var.gitops_addons_repo}"
51+
gitops_addons_basepath = var.gitops_addons_basepath
52+
gitops_addons_path = var.gitops_addons_path
53+
gitops_addons_revision = var.gitops_addons_revision
5354

5455
aws_addons = {
5556
enable_cert_manager = true
@@ -106,17 +107,15 @@ locals {
106107
aws_upbound_crossplane_iam_role_arn = module.crossplane_irsa_aws.iam_role_arn
107108
},
108109
{
109-
gitops_bridge_repo_url = local.gitops_url
110-
gitops_bridge_repo_revision = local.gitops_revision
110+
addons_repo_url = local.gitops_addons_url
111+
addons_repo_basepath = local.gitops_addons_basepath
112+
addons_repo_path = local.gitops_addons_path
113+
addons_repo_revision = local.gitops_addons_revision
111114
}
112115
)
113116

114117
argocd_bootstrap_app_of_apps = {
115-
addons = templatefile("${path.module}/bootstrap/addons.yaml", {
116-
repoURL = local.gitops_url
117-
targetRevision = local.gitops_revision
118-
path = local.gitops_path
119-
})
118+
addons = file("${path.module}/bootstrap/addons.yaml")
120119
workloads = file("${path.module}/bootstrap/workloads.yaml")
121120
}
122121

0 commit comments

Comments
 (0)