diff --git a/README.md b/README.md
index 2965a32..5ccba87 100644
--- a/README.md
+++ b/README.md
@@ -36,32 +36,26 @@ locals {
}
)
- argocd_bootstrap_app_of_apps = {
+ argocd_apps = {
addons = file("${path.module}/bootstrap/addons.yaml")
+ workloads = file("${path.module}/bootstrap/workloads.yaml")
}
}
-###########################################################################
-# GitOps Bridge: Metadata
-###########################################################################
-module "gitops_bridge_metadata" {
- source = "github.com/gitops-bridge-dev/gitops-bridge-argocd-metadata-terraform?ref=v1.0.0"
-
- cluster_name = local.name
- environment = local.environment
- metadata = local.addons_metadata
- addons = local.addons
-}
-
-###########################################################################
+################################################################################
# GitOps Bridge: Bootstrap
-###########################################################################
+################################################################################
module "gitops_bridge_bootstrap" {
- source = "github.com/gitops-bridge-dev/gitops-bridge-argocd-bootstrap-terraform?ref=v1.0.0"
+ source = "github.com/gitops-bridge-dev/gitops-bridge-argocd-bootstrap-terraform?ref=v2.0.0"
- argocd_cluster = module.gitops_bridge_metadata.argocd
- argocd_bootstrap_app_of_apps = local.argocd_bootstrap_app_of_apps
+ cluster = {
+ cluster_name = local.name
+ environment = local.environment
+ metadata = local.addons_metadata
+ addons = local.addons
+ }
+ apps = local.argocd_apps
}
```
@@ -73,7 +67,6 @@ module "gitops_bridge_bootstrap" {
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.0 |
| [helm](#requirement\_helm) | >= 2.10.1 |
-| [kubectl](#requirement\_kubectl) | >= 1.14 |
| [kubernetes](#requirement\_kubernetes) | >= 2.22.0 |
## Providers
@@ -99,11 +92,11 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
+| [apps](#input\_apps) | argocd app of apps to deploy | `any` | `{}` | no |
| [argocd](#input\_argocd) | argocd helm options | `any` | `{}` | no |
-| [argocd\_bootstrap\_app\_of\_apps](#input\_argocd\_bootstrap\_app\_of\_apps) | argocd app of apps to deploy | `any` | `{}` | no |
-| [argocd\_cluster](#input\_argocd\_cluster) | argocd cluster secret | `any` | `null` | no |
-| [argocd\_create\_install](#input\_argocd\_create\_install) | Deploy argocd helm | `bool` | `true` | no |
+| [cluster](#input\_cluster) | argocd cluster secret | `any` | `null` | no |
| [create](#input\_create) | Create terraform resources | `bool` | `true` | no |
+| [install](#input\_install) | Deploy argocd helm | `bool` | `true` | no |
## Outputs
diff --git a/main.tf b/main.tf
index 2f6cdc5..892b418 100644
--- a/main.tf
+++ b/main.tf
@@ -2,7 +2,7 @@
# Install ArgoCD
################################################################################
resource "helm_release" "argocd" {
- count = var.create && var.argocd_create_install ? 1 : 0
+ count = var.create && var.install ? 1 : 0
# https://github.com/argoproj/argo-helm/blob/main/charts/argo-cd/Chart.yaml
# (there is no offical helm chart for argocd)
@@ -72,16 +72,64 @@ resource "helm_release" "argocd" {
}
+
+################################################################################
+# ArgoCD Cluster
+################################################################################
+locals {
+ cluster_name = try(var.cluster.cluster_name, "in-cluster")
+ environment = try(var.cluster.environment, "dev")
+ argocd_labels = merge({
+ cluster_name = local.cluster_name
+ environment = local.environment
+ enable_argocd = true
+ "argocd.argoproj.io/secret-type" = "cluster"
+ },
+ try(var.cluster.addons, {})
+ )
+ argocd_annotations = merge(
+ {
+ cluster_name = local.cluster_name
+ environment = local.environment
+ },
+ try(var.cluster.metadata, {})
+ )
+}
+
+locals {
+ config = <<-EOT
+ {
+ "tlsClientConfig": {
+ "insecure": false
+ }
+ }
+ EOT
+ argocd = {
+ apiVersion = "v1"
+ kind = "Secret"
+ metadata = {
+ name = try(var.cluster.secret_name, local.cluster_name)
+ namespace = try(var.cluster.secret_namespace, "argocd")
+ annotations = local.argocd_annotations
+ labels = local.argocd_labels
+ }
+ stringData = {
+ name = local.cluster_name
+ server = try(var.cluster.server, "https://kubernetes.default.svc")
+ config = try(var.cluster.config, local.config)
+ }
+ }
+}
resource "kubernetes_secret_v1" "cluster" {
- count = var.create && (var.argocd_cluster != null) ? 1 : 0
+ count = var.create && (var.cluster != null) ? 1 : 0
metadata {
- name = var.argocd_cluster.metadata.name
- namespace = var.argocd_cluster.metadata.namespace
- annotations = var.argocd_cluster.metadata.annotations
- labels = var.argocd_cluster.metadata.labels
+ name = local.argocd.metadata.name
+ namespace = local.argocd.metadata.namespace
+ annotations = local.argocd.metadata.annotations
+ labels = local.argocd.metadata.labels
}
- data = var.argocd_cluster.stringData
+ data = local.argocd.stringData
depends_on = [helm_release.argocd]
}
@@ -91,7 +139,7 @@ resource "kubernetes_secret_v1" "cluster" {
# Create App of Apps
################################################################################
resource "helm_release" "bootstrap" {
- for_each = var.create ? var.argocd_bootstrap_app_of_apps : {}
+ for_each = var.create ? var.apps : {}
name = each.key
namespace = try(var.argocd.namespace, "argocd")
diff --git a/tests/complete/bootstrap/workloads.yaml b/tests/complete/bootstrap/workloads.yaml
new file mode 100644
index 0000000..60293af
--- /dev/null
+++ b/tests/complete/bootstrap/workloads.yaml
@@ -0,0 +1,20 @@
+apiVersion: argoproj.io/v1alpha1
+kind: Application
+metadata:
+ name: bootstrap-workloads
+ namespace: 'argocd'
+ finalizers:
+ - resources-finalizer.argocd.argoproj.io
+spec:
+ destination:
+ server: https://kubernetes.default.svc
+ namespace: 'guestbook'
+ project: default
+ source:
+ path: helm-guestbook
+ repoURL: https://github.com/argoproj/argocd-example-apps
+ targetRevision: HEAD
+ syncPolicy:
+ automated: {}
+ syncOptions:
+ - CreateNamespace=true
diff --git a/tests/complete/main.tf b/tests/complete/main.tf
index 4811407..7c3930f 100644
--- a/tests/complete/main.tf
+++ b/tests/complete/main.tf
@@ -46,23 +46,13 @@ locals {
}
)
- argocd_bootstrap_app_of_apps = {
+ argocd_apps = {
addons = file("${path.module}/bootstrap/addons.yaml")
+ workloads = file("${path.module}/bootstrap/workloads.yaml")
}
}
-################################################################################
-# GitOps Bridge: Metadata
-################################################################################
-module "gitops_bridge_metadata" {
- source = "github.com/gitops-bridge-dev/gitops-bridge-argocd-metadata-terraform?ref=v1.0.0"
-
- cluster_name = local.name
- environment = local.environment
- metadata = local.addons_metadata
- addons = local.addons
-}
################################################################################
# GitOps Bridge: Bootstrap
@@ -70,6 +60,11 @@ module "gitops_bridge_metadata" {
module "gitops_bridge_bootstrap" {
source = "../../"
- argocd_cluster = module.gitops_bridge_metadata.argocd
- argocd_bootstrap_app_of_apps = local.argocd_bootstrap_app_of_apps
+ cluster = {
+ cluster_name = local.name
+ environment = local.environment
+ metadata = local.addons_metadata
+ addons = local.addons
+ }
+ apps = local.argocd_apps
}
diff --git a/tests/complete/versions.tf b/tests/complete/versions.tf
index bbd6497..7f108cc 100644
--- a/tests/complete/versions.tf
+++ b/tests/complete/versions.tf
@@ -6,10 +6,6 @@ terraform {
source = "hashicorp/helm"
version = ">= 2.10.1"
}
- kubectl = {
- source = "gavinbunney/kubectl"
- version = ">= 1.14"
- }
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.22.0"
diff --git a/variables.tf b/variables.tf
index fe33117..641ade9 100644
--- a/variables.tf
+++ b/variables.tf
@@ -8,19 +8,19 @@ variable "argocd" {
type = any
default = {}
}
-variable "argocd_create_install" {
+variable "install" {
description = "Deploy argocd helm"
type = bool
default = true
}
-variable "argocd_cluster" {
+variable "cluster" {
description = "argocd cluster secret"
type = any
default = null
}
-variable "argocd_bootstrap_app_of_apps" {
+variable "apps" {
description = "argocd app of apps to deploy"
type = any
default = {}
diff --git a/versions.tf b/versions.tf
index bbd6497..7f108cc 100644
--- a/versions.tf
+++ b/versions.tf
@@ -6,10 +6,6 @@ terraform {
source = "hashicorp/helm"
version = ">= 2.10.1"
}
- kubectl = {
- source = "gavinbunney/kubectl"
- version = ">= 1.14"
- }
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.22.0"