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

Commit d420ee5

Browse files
authored
Use helm for bootstrap apps (#6)
* use helm Signed-off-by: Carlos Santana <[email protected]> * fix rendering Signed-off-by: Carlos Santana <[email protected]> * EOL Signed-off-by: Carlos Santana <[email protected]> * update all files Signed-off-by: Carlos Santana <[email protected]> --------- Signed-off-by: Carlos Santana <[email protected]>
1 parent 5765fce commit d420ee5

File tree

8 files changed

+137
-6
lines changed

8 files changed

+137
-6
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ module "gitops_bridge_bootstrap" {
8181
| Name | Version |
8282
|------|---------|
8383
| <a name="provider_helm"></a> [helm](#provider\_helm) | >= 2.10.1 |
84-
| <a name="provider_kubectl"></a> [kubectl](#provider\_kubectl) | >= 1.14 |
8584
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | >= 2.22.0 |
8685

8786
## Modules
@@ -93,7 +92,7 @@ No modules.
9392
| Name | Type |
9493
|------|------|
9594
| [helm_release.argocd](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
96-
| [kubectl_manifest.bootstrap](https://registry.terraform.io/providers/gavinbunney/kubectl/latest/docs/resources/manifest) | resource |
95+
| [helm_release.bootstrap](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
9796
| [kubernetes_secret_v1.cluster](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret_v1) | resource |
9897

9998
## Inputs

charts/resources/.helmignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/resources/Chart.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: resources
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 1.0.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.0.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{ range .Values.resources }}
2+
---
3+
{{ if typeIs "string" . }}
4+
{{- tpl . $ }}
5+
{{- else }}
6+
{{- toYaml . }}
7+
{{- end }}
8+
{{ end }}

charts/resources/values.yaml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
## Define Pure kubernetes resources
2+
# resources -- Define resources to be deployed by the raw chart
3+
resources: []
4+
# - apiVersion: argoproj.io/v1alpha1
5+
# kind: ApplicationSet
6+
# metadata:
7+
# name: bootstrap-addons
8+
# namespace: argocd
9+
# spec:
10+
# syncPolicy:
11+
# preserveResourcesOnDeletion: true
12+
# generators:
13+
# - clusters:
14+
# selector:
15+
# matchExpressions:
16+
# - key: akuity.io/argo-cd-cluster-name
17+
# operator: NotIn
18+
# values: [in-cluster]
19+
# template:
20+
# metadata:
21+
# name: 'bootstrap-addons'
22+
# spec:
23+
# project: default
24+
# source:
25+
# repoURL: '{{metadata.annotations.addons_repo_url}}'
26+
# path: '{{metadata.annotations.addons_repo_basepath}}{{metadata.annotations.addons_repo_path}}'
27+
# targetRevision: '{{metadata.annotations.addons_repo_revision}}'
28+
# directory:
29+
# recurse: true
30+
# exclude: exclude/*
31+
# destination:
32+
# namespace: 'argocd'
33+
# name: '{{name}}'
34+
# syncPolicy:
35+
# automated: {}
36+
# - |
37+
# apiVersion: argoproj.io/v1alpha1
38+
# kind: ApplicationSet
39+
# metadata:
40+
# name: bootstrap-addons
41+
# namespace: argocd
42+
# spec:
43+
# syncPolicy:
44+
# preserveResourcesOnDeletion: true
45+
# generators:
46+
# - clusters:
47+
# selector:
48+
# matchExpressions:
49+
# - key: akuity.io/argo-cd-cluster-name
50+
# operator: NotIn
51+
# values: [in-cluster]
52+
# template:
53+
# metadata:
54+
# name: 'bootstrap-addons'
55+
# spec:
56+
# project: default
57+
# source:
58+
# repoURL: '{{metadata.annotations.addons_repo_url}}'
59+
# path: '{{metadata.annotations.addons_repo_basepath}}{{metadata.annotations.addons_repo_path}}'
60+
# targetRevision: '{{metadata.annotations.addons_repo_revision}}'
61+
# directory:
62+
# recurse: true
63+
# exclude: exclude/*
64+
# destination:
65+
# namespace: 'argocd'
66+
# name: '{{name}}'
67+
# syncPolicy:
68+
# automated: {}

main.tf

+12-2
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,20 @@ resource "kubernetes_secret_v1" "cluster" {
9090
################################################################################
9191
# Create App of Apps
9292
################################################################################
93-
resource "kubectl_manifest" "bootstrap" {
93+
resource "helm_release" "bootstrap" {
9494
for_each = var.create ? var.argocd_bootstrap_app_of_apps : {}
9595

96-
yaml_body = each.value
96+
name = each.key
97+
namespace = try(var.argocd.namespace, "argocd")
98+
chart = "${path.module}/charts/resources"
99+
version = "1.0.0"
100+
101+
values = [
102+
<<-EOT
103+
resources:
104+
- ${indent(4, each.value)}
105+
EOT
106+
]
97107

98108
depends_on = [resource.kubernetes_secret_v1.cluster]
99109
}

outputs.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ output "cluster" {
88
}
99
output "apps" {
1010
description = "ArgoCD apps"
11-
value = try(kubectl_manifest.bootstrap, null)
11+
value = try(helm_release.bootstrap, null)
1212
}

tests/complete/bootstrap/addons.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
apiVersion: argoproj.io/v1alpha1
32
kind: ApplicationSet
43
metadata:

0 commit comments

Comments
 (0)