Skip to content
This repository was archived by the owner on Apr 14, 2024. It is now read-only.

Commit 1e45033

Browse files
authored
intial-2.0 (#10)
Signed-off-by: Carlos Santana <[email protected]>
1 parent d420ee5 commit 1e45033

File tree

7 files changed

+103
-55
lines changed

7 files changed

+103
-55
lines changed

README.md

+15-22
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,26 @@ locals {
3636
}
3737
)
3838
39-
argocd_bootstrap_app_of_apps = {
39+
argocd_apps = {
4040
addons = file("${path.module}/bootstrap/addons.yaml")
41+
workloads = file("${path.module}/bootstrap/workloads.yaml")
4142
}
4243
4344
}
4445
45-
###########################################################################
46-
# GitOps Bridge: Metadata
47-
###########################################################################
48-
module "gitops_bridge_metadata" {
49-
source = "github.com/gitops-bridge-dev/gitops-bridge-argocd-metadata-terraform?ref=v1.0.0"
50-
51-
cluster_name = local.name
52-
environment = local.environment
53-
metadata = local.addons_metadata
54-
addons = local.addons
55-
}
56-
57-
###########################################################################
46+
################################################################################
5847
# GitOps Bridge: Bootstrap
59-
###########################################################################
48+
################################################################################
6049
module "gitops_bridge_bootstrap" {
61-
source = "github.com/gitops-bridge-dev/gitops-bridge-argocd-bootstrap-terraform?ref=v1.0.0"
50+
source = "github.com/gitops-bridge-dev/gitops-bridge-argocd-bootstrap-terraform?ref=v2.0.0"
6251
63-
argocd_cluster = module.gitops_bridge_metadata.argocd
64-
argocd_bootstrap_app_of_apps = local.argocd_bootstrap_app_of_apps
52+
cluster = {
53+
cluster_name = local.name
54+
environment = local.environment
55+
metadata = local.addons_metadata
56+
addons = local.addons
57+
}
58+
apps = local.argocd_apps
6559
}
6660
6761
```
@@ -73,7 +67,6 @@ module "gitops_bridge_bootstrap" {
7367
|------|---------|
7468
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
7569
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.10.1 |
76-
| <a name="requirement_kubectl"></a> [kubectl](#requirement\_kubectl) | >= 1.14 |
7770
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.22.0 |
7871

7972
## Providers
@@ -99,11 +92,11 @@ No modules.
9992

10093
| Name | Description | Type | Default | Required |
10194
|------|-------------|------|---------|:--------:|
95+
| <a name="input_apps"></a> [apps](#input\_apps) | argocd app of apps to deploy | `any` | `{}` | no |
10296
| <a name="input_argocd"></a> [argocd](#input\_argocd) | argocd helm options | `any` | `{}` | no |
103-
| <a name="input_argocd_bootstrap_app_of_apps"></a> [argocd\_bootstrap\_app\_of\_apps](#input\_argocd\_bootstrap\_app\_of\_apps) | argocd app of apps to deploy | `any` | `{}` | no |
104-
| <a name="input_argocd_cluster"></a> [argocd\_cluster](#input\_argocd\_cluster) | argocd cluster secret | `any` | `null` | no |
105-
| <a name="input_argocd_create_install"></a> [argocd\_create\_install](#input\_argocd\_create\_install) | Deploy argocd helm | `bool` | `true` | no |
97+
| <a name="input_cluster"></a> [cluster](#input\_cluster) | argocd cluster secret | `any` | `null` | no |
10698
| <a name="input_create"></a> [create](#input\_create) | Create terraform resources | `bool` | `true` | no |
99+
| <a name="input_install"></a> [install](#input\_install) | Deploy argocd helm | `bool` | `true` | no |
107100

108101
## Outputs
109102

main.tf

+56-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Install ArgoCD
33
################################################################################
44
resource "helm_release" "argocd" {
5-
count = var.create && var.argocd_create_install ? 1 : 0
5+
count = var.create && var.install ? 1 : 0
66

77
# https://github.com/argoproj/argo-helm/blob/main/charts/argo-cd/Chart.yaml
88
# (there is no offical helm chart for argocd)
@@ -72,16 +72,64 @@ resource "helm_release" "argocd" {
7272

7373
}
7474

75+
76+
################################################################################
77+
# ArgoCD Cluster
78+
################################################################################
79+
locals {
80+
cluster_name = try(var.cluster.cluster_name, "in-cluster")
81+
environment = try(var.cluster.environment, "dev")
82+
argocd_labels = merge({
83+
cluster_name = local.cluster_name
84+
environment = local.environment
85+
enable_argocd = true
86+
"argocd.argoproj.io/secret-type" = "cluster"
87+
},
88+
try(var.cluster.addons, {})
89+
)
90+
argocd_annotations = merge(
91+
{
92+
cluster_name = local.cluster_name
93+
environment = local.environment
94+
},
95+
try(var.cluster.metadata, {})
96+
)
97+
}
98+
99+
locals {
100+
config = <<-EOT
101+
{
102+
"tlsClientConfig": {
103+
"insecure": false
104+
}
105+
}
106+
EOT
107+
argocd = {
108+
apiVersion = "v1"
109+
kind = "Secret"
110+
metadata = {
111+
name = try(var.cluster.secret_name, local.cluster_name)
112+
namespace = try(var.cluster.secret_namespace, "argocd")
113+
annotations = local.argocd_annotations
114+
labels = local.argocd_labels
115+
}
116+
stringData = {
117+
name = local.cluster_name
118+
server = try(var.cluster.server, "https://kubernetes.default.svc")
119+
config = try(var.cluster.config, local.config)
120+
}
121+
}
122+
}
75123
resource "kubernetes_secret_v1" "cluster" {
76-
count = var.create && (var.argocd_cluster != null) ? 1 : 0
124+
count = var.create && (var.cluster != null) ? 1 : 0
77125

78126
metadata {
79-
name = var.argocd_cluster.metadata.name
80-
namespace = var.argocd_cluster.metadata.namespace
81-
annotations = var.argocd_cluster.metadata.annotations
82-
labels = var.argocd_cluster.metadata.labels
127+
name = local.argocd.metadata.name
128+
namespace = local.argocd.metadata.namespace
129+
annotations = local.argocd.metadata.annotations
130+
labels = local.argocd.metadata.labels
83131
}
84-
data = var.argocd_cluster.stringData
132+
data = local.argocd.stringData
85133

86134
depends_on = [helm_release.argocd]
87135
}
@@ -91,7 +139,7 @@ resource "kubernetes_secret_v1" "cluster" {
91139
# Create App of Apps
92140
################################################################################
93141
resource "helm_release" "bootstrap" {
94-
for_each = var.create ? var.argocd_bootstrap_app_of_apps : {}
142+
for_each = var.create ? var.apps : {}
95143

96144
name = each.key
97145
namespace = try(var.argocd.namespace, "argocd")
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: Application
3+
metadata:
4+
name: bootstrap-workloads
5+
namespace: 'argocd'
6+
finalizers:
7+
- resources-finalizer.argocd.argoproj.io
8+
spec:
9+
destination:
10+
server: https://kubernetes.default.svc
11+
namespace: 'guestbook'
12+
project: default
13+
source:
14+
path: helm-guestbook
15+
repoURL: https://github.com/argoproj/argocd-example-apps
16+
targetRevision: HEAD
17+
syncPolicy:
18+
automated: {}
19+
syncOptions:
20+
- CreateNamespace=true

tests/complete/main.tf

+9-14
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,25 @@ locals {
4646
}
4747
)
4848

49-
argocd_bootstrap_app_of_apps = {
49+
argocd_apps = {
5050
addons = file("${path.module}/bootstrap/addons.yaml")
51+
workloads = file("${path.module}/bootstrap/workloads.yaml")
5152
}
5253

5354
}
5455

55-
################################################################################
56-
# GitOps Bridge: Metadata
57-
################################################################################
58-
module "gitops_bridge_metadata" {
59-
source = "github.com/gitops-bridge-dev/gitops-bridge-argocd-metadata-terraform?ref=v1.0.0"
60-
61-
cluster_name = local.name
62-
environment = local.environment
63-
metadata = local.addons_metadata
64-
addons = local.addons
65-
}
6656

6757
################################################################################
6858
# GitOps Bridge: Bootstrap
6959
################################################################################
7060
module "gitops_bridge_bootstrap" {
7161
source = "../../"
7262

73-
argocd_cluster = module.gitops_bridge_metadata.argocd
74-
argocd_bootstrap_app_of_apps = local.argocd_bootstrap_app_of_apps
63+
cluster = {
64+
cluster_name = local.name
65+
environment = local.environment
66+
metadata = local.addons_metadata
67+
addons = local.addons
68+
}
69+
apps = local.argocd_apps
7570
}

tests/complete/versions.tf

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ terraform {
66
source = "hashicorp/helm"
77
version = ">= 2.10.1"
88
}
9-
kubectl = {
10-
source = "gavinbunney/kubectl"
11-
version = ">= 1.14"
12-
}
139
kubernetes = {
1410
source = "hashicorp/kubernetes"
1511
version = ">= 2.22.0"

variables.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ variable "argocd" {
88
type = any
99
default = {}
1010
}
11-
variable "argocd_create_install" {
11+
variable "install" {
1212
description = "Deploy argocd helm"
1313
type = bool
1414
default = true
1515
}
1616

17-
variable "argocd_cluster" {
17+
variable "cluster" {
1818
description = "argocd cluster secret"
1919
type = any
2020
default = null
2121
}
2222

23-
variable "argocd_bootstrap_app_of_apps" {
23+
variable "apps" {
2424
description = "argocd app of apps to deploy"
2525
type = any
2626
default = {}

versions.tf

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ terraform {
66
source = "hashicorp/helm"
77
version = ">= 2.10.1"
88
}
9-
kubectl = {
10-
source = "gavinbunney/kubectl"
11-
version = ">= 1.14"
12-
}
139
kubernetes = {
1410
source = "hashicorp/kubernetes"
1511
version = ">= 2.22.0"

0 commit comments

Comments
 (0)