diff --git a/kubernetes/helm_charts/argocd-base-application/Chart.yaml b/kubernetes/helm_charts/app-of-apps/Chart.yaml similarity index 97% rename from kubernetes/helm_charts/argocd-base-application/Chart.yaml rename to kubernetes/helm_charts/app-of-apps/Chart.yaml index a3a78fc..a575c6c 100644 --- a/kubernetes/helm_charts/argocd-base-application/Chart.yaml +++ b/kubernetes/helm_charts/app-of-apps/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 -name: argocd-base-application +name: app-of-apps description: Helm chart for installing the ArgoCD base application # A chart can be either an 'application' or a 'library' chart. diff --git a/kubernetes/helm_charts/argocd-base-application/templates/argocd-base-application.yaml b/kubernetes/helm_charts/app-of-apps/templates/app-of-apps.yaml similarity index 70% rename from kubernetes/helm_charts/argocd-base-application/templates/argocd-base-application.yaml rename to kubernetes/helm_charts/app-of-apps/templates/app-of-apps.yaml index f14e041..cbe5943 100644 --- a/kubernetes/helm_charts/argocd-base-application/templates/argocd-base-application.yaml +++ b/kubernetes/helm_charts/app-of-apps/templates/app-of-apps.yaml @@ -1,7 +1,7 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: applications + name: app-of-apps namespace: argocd finalizers: - resources-finalizer.argocd.argoproj.io @@ -11,6 +11,6 @@ spec: server: https://kubernetes.default.svc namespace: argocd source: - {{- toYaml .Values.source | nindent 4 }} + {{- .Values.source | nindent 4 }} syncPolicy: - {{- toYaml .Values.syncPolicy | nindent 4 }} \ No newline at end of file + {{- .Values.syncPolicy | nindent 4 }} \ No newline at end of file diff --git a/kubernetes/helm_charts/argocd-base-application/values.yaml b/kubernetes/helm_charts/app-of-apps/values.yaml similarity index 100% rename from kubernetes/helm_charts/argocd-base-application/values.yaml rename to kubernetes/helm_charts/app-of-apps/values.yaml diff --git a/kubernetes/helm_releases.tf b/kubernetes/helm_releases.tf index 2b88fc8..3f9b8c7 100644 --- a/kubernetes/helm_releases.tf +++ b/kubernetes/helm_releases.tf @@ -1,12 +1,12 @@ resource "helm_release" "argocd" { - name = "argo-cd" - namespace = "argocd" - create_namespace = true - chart = "argo-cd" - version = "9.2.4" - repository = "https://argoproj.github.io/argo-helm" - timeout = 120 - set = local.argocd_values + depends_on = [kubernetes_namespace_v1.argocd] + name = "argo-cd" + chart = "argo-cd" + version = "9.2.4" + repository = "https://argoproj.github.io/argo-helm" + namespace = kubernetes_namespace_v1.argocd.id + timeout = 120 + set = local.argocd_values } resource "helm_release" "cilium_lb_config" { @@ -30,8 +30,9 @@ resource "helm_release" "cilium_lb_config" { resource "helm_release" "argocd_app_of_apps" { count = var.install_argocd_app_of_apps ? 1 : 0 depends_on = [helm_release.argocd] - name = "cilium-lb-config" - chart = "${path.module}/helm_charts/cilium-lb-config" + name = "app-of-apps" + chart = "${path.module}/helm_charts/app-of-apps" + namespace = kubernetes_namespace_v1.argocd.id timeout = 60 set = [ { @@ -43,4 +44,27 @@ resource "helm_release" "argocd_app_of_apps" { value = var.argocd_app_of_apps_sync_policy }, ] -} \ No newline at end of file +} + +# data "helm_template" "argocd_app_of_apps" { +# +# depends_on = [helm_release.argocd] +# name = "app-of-apps" +# chart = "${path.module}/helm_charts/app-of-apps" +# namespace = kubernetes_namespace_v1.argocd.id +# timeout = 60 +# set = [ +# { +# name = "source" +# value = var.argocd_app_of_apps_source +# }, +# { +# name = "syncPolicy" +# value = var.argocd_app_of_apps_sync_policy +# }, +# ] +# } +# +# output "argocd_app_of_apps_rendered_yaml" { +# value = data.helm_template.argocd_app_of_apps.manifest +# } \ No newline at end of file diff --git a/kubernetes/namespaces.tf b/kubernetes/namespaces.tf new file mode 100644 index 0000000..22df6b6 --- /dev/null +++ b/kubernetes/namespaces.tf @@ -0,0 +1,5 @@ +resource "kubernetes_namespace_v1" "argocd" { + metadata { + name = "argocd" + } +} \ No newline at end of file diff --git a/kubernetes/providers.tf b/kubernetes/providers.tf index cced4f4..b34bed2 100644 --- a/kubernetes/providers.tf +++ b/kubernetes/providers.tf @@ -1,5 +1,9 @@ terraform { required_providers { + kubernetes = { + source = "hashicorp/kubernetes" + version = "3.0.1" + } helm = { source = "hashicorp/helm" version = "3.1.1" @@ -7,6 +11,11 @@ terraform { } } +provider "kubernetes" { + config_path = var.kubernetes_config_path + config_context = var.Kubernetes_config_context +} + provider "helm" { kubernetes = { config_path = var.kubernetes_config_path diff --git a/kubernetes/secrets.tf b/kubernetes/secrets.tf index 8c556df..10cd37a 100644 --- a/kubernetes/secrets.tf +++ b/kubernetes/secrets.tf @@ -1,8 +1,8 @@ resource "kubernetes_secret_v1" "argocd_app_of_apps_git_repo" { count = var.install_argocd_app_of_apps_git_repo_secret ? 1 : 0 - depends_on = [helm_release.argocd_app_of_apps] + depends_on = [kubernetes_namespace_v1.argocd] metadata { - namespace = "argocd" + namespace = kubernetes_namespace_v1.argocd.id name = "argocd-app-of-apps-git-repo" labels = { "argocd.argoproj.io/secret-type" = "repository" diff --git a/kubernetes/variables.tf b/kubernetes/variables.tf index b09b424..4885beb 100644 --- a/kubernetes/variables.tf +++ b/kubernetes/variables.tf @@ -43,24 +43,22 @@ variable "install_argocd_app_of_apps" { variable "argocd_app_of_apps_source" { type = string default = <<-EOT -source: - repoURL: https://github.com/max-pfeiffer/proxmox-talos-opentofu - targetRevision: main - path: argocd/root - directory: - recurse: true +repoURL: https://github.com/max-pfeiffer/proxmox-talos-opentofu +targetRevision: feature/make-gitops-part-configurable +path: argocd +directory: + recurse: true EOT } variable "argocd_app_of_apps_sync_policy" { type = string default = <<-EOT -syncPolicy: - automated: - prune: true - selfHeal: true - syncOptions: - - SkipDryRunOnMissingResource=true +automated: + prune: true + selfHeal: true +syncOptions: +- SkipDryRunOnMissingResource=true EOT }