diff --git a/_templates/argo_app.libsonnet b/_templates/argo_app.libsonnet deleted file mode 100644 index 10e76d1..0000000 --- a/_templates/argo_app.libsonnet +++ /dev/null @@ -1,17 +0,0 @@ -local base = import "argo_base.libsonnet"; - -base + { - repo:: error "repo must be defined", - version:: error "version must be defined", - path:: error "path must be defined", - recursive:: true, - - spec+: { - source: { - repoURL: $.repo, - path: $.path, - targetRevision: $.version, - directory: { recurse: $.recursive }, - } - } -} diff --git a/_templates/argo_base.libsonnet b/_templates/argo_base.libsonnet deleted file mode 100644 index 8f697f9..0000000 --- a/_templates/argo_base.libsonnet +++ /dev/null @@ -1,38 +0,0 @@ -{ - name:: error "name must be defined", - namespace:: $.name, - syncOptions:: ["CreateNamespace=true"], - retryLimit:: 5, - sync_wave:: 0, - - apiVersion: "argoproj.io/v1alpha1", - kind: "Application", - metadata: { - name: $.name, - namespace: "argocd", - annotations: { "argocd.argoproj.io/sync-wave": std.toString($.sync_wave) }, - finalizers: ["resources-finalizer.argocd.argoproj.io"], - }, - spec: { - project: "baseline", - destination: { - server: "https://kubernetes.default.svc", - namespace: $.namespace, - }, - syncPolicy: { - automated: { - selfHeal: true, - prune: true, - }, - retry: { - limit: $.retryLimit, - backoff: { - duration: "5s", - factor: 2, - maxDuration: "5m", - }, - }, - syncOptions: $.syncOptions, - } - } -} diff --git a/_templates/argo_helm_app.libsonnet b/_templates/argo_helm_app.libsonnet deleted file mode 100644 index 8e4a126..0000000 --- a/_templates/argo_helm_app.libsonnet +++ /dev/null @@ -1,29 +0,0 @@ -local base = import "argo_base.libsonnet"; - -base + { - repo:: error "repo must be defined", - chart:: $.name, - version:: error "version must be defined", - skipCrds:: false, - values:: "", - - spec+: { - source+: { - repoURL: $.repo, - chart: $.chart, - targetRevision: $.version, - } - - + ( - if std.length($.values) > 0 then - { helm+: { values: $.values } } else {} - ) - - + ( - if $.skipCrds then - { helm+: { skipCrds: true } } else {} - ) - - } - -} diff --git a/_templates/argocd_app.libsonnet b/_templates/argocd_app.libsonnet new file mode 100644 index 0000000..03ed2dd --- /dev/null +++ b/_templates/argocd_app.libsonnet @@ -0,0 +1,79 @@ +{ + # generic parameters + name:: $.chart, + namespace:: $.name, + + syncOptions:: ["CreateNamespace=true"], + retryLimit:: 5, + sync_wave:: 0, + + # source parameters + repo:: error "repository must be defined", + version:: error "version must be defined", + + # helm chart parameters + chart:: "", + skipCrds:: false, + values:: "", + + # directory parameters + path:: "", + recursive:: true, + + + apiVersion: "argoproj.io/v1alpha1", + kind: "Application", + metadata: { + name: $.name, + namespace: "argocd", + annotations: { "argocd.argoproj.io/sync-wave": std.toString($.sync_wave) }, + finalizers: ["resources-finalizer.argocd.argoproj.io"], + }, + spec: { + project: "baseline", + destination: { + server: "https://kubernetes.default.svc", + namespace: $.namespace, + }, + source: { + repoURL: $.repo, + targetRevision: $.version, + }, + syncPolicy: { + automated: { + selfHeal: true, + prune: true, + }, + retry: { + limit: $.retryLimit, + backoff: { + duration: "5s", + factor: 2, + maxDuration: "5m", + }, + }, + syncOptions: $.syncOptions, + } + } + + + ( # append chart name if defined + if std.length($.chart) > 0 then + { source+: { chart: $.chart, } } else {} + ) + + + ( # set helm values + if std.length($.values) > 0 then + { source+: { helm+: { values: $.values } } } else {} + ) + + + ( # set skipCRDs if defined + if $.skipCrds then + { source+: { helm+: { skipCrds: true } } } else {} + ) + + + ( # append generic directory path and recurse option + if std.length($.path) > 0 then + { source+: { path: $.path, directory: { recurse: $.recursive } } } else {} + ) + +} diff --git a/k8s-manifests/cert-manager.jsonnet b/k8s-manifests/cert-manager.jsonnet index a2021d2..93ac0a7 100644 --- a/k8s-manifests/cert-manager.jsonnet +++ b/k8s-manifests/cert-manager.jsonnet @@ -1,8 +1,8 @@ -local helmapp = import "../_templates/argo_helm_app.libsonnet"; +local app = import "../_templates/argocd_app.libsonnet"; [ -helmapp + { - name:: "cert-manager", +app + { + chart:: "cert-manager", repo:: "https://charts.jetstack.io", version:: "v1.8.*", values:: ||| diff --git a/k8s-manifests/ingress-nginx.jsonnet b/k8s-manifests/ingress-nginx.jsonnet index b71fd15..06f33f4 100644 --- a/k8s-manifests/ingress-nginx.jsonnet +++ b/k8s-manifests/ingress-nginx.jsonnet @@ -1,8 +1,8 @@ -local helmapp = import "../_templates/argo_helm_app.libsonnet"; +local app = import "../_templates/argocd_app.libsonnet"; [ -helmapp + { - name:: "ingress-nginx", +app + { + chart:: "ingress-nginx", repo:: "https://kubernetes.github.io/ingress-nginx", version:: "4.0.*", values:: ||| diff --git a/k8s-manifests/keel.jsonnet b/k8s-manifests/keel.jsonnet index 5790692..ab98904 100644 --- a/k8s-manifests/keel.jsonnet +++ b/k8s-manifests/keel.jsonnet @@ -1,8 +1,8 @@ -local helmapp = import "../_templates/argo_helm_app.libsonnet"; +local app = import "../_templates/argocd_app.libsonnet"; [ -helmapp + { - name:: "keel", +app + { + chart:: "keel", repo:: "https://charts.keel.sh", version:: "0.9.*", values:: ||| diff --git a/k8s-manifests/monitoring/loki-stack.jsonnet b/k8s-manifests/monitoring/loki-stack.jsonnet index bb6aaa3..5f3e071 100644 --- a/k8s-manifests/monitoring/loki-stack.jsonnet +++ b/k8s-manifests/monitoring/loki-stack.jsonnet @@ -1,11 +1,11 @@ -local helmapp = import "../../_templates/argo_helm_app.libsonnet"; +local app = import "../../_templates/argocd_app.libsonnet"; [ -helmapp + { +app + { name:: "loki", namespace:: "metrics", - repo:: "https://grafana.github.io/helm-charts", chart:: "loki-stack", + repo:: "https://grafana.github.io/helm-charts", version:: "2.6.*", values:: ||| loki: diff --git a/k8s-manifests/monitoring/prometheus-stack.jsonnet b/k8s-manifests/monitoring/prometheus-stack.jsonnet index 38f03ab..14064ff 100644 --- a/k8s-manifests/monitoring/prometheus-stack.jsonnet +++ b/k8s-manifests/monitoring/prometheus-stack.jsonnet @@ -1,6 +1,5 @@ # see https://blog.ediri.io/kube-prometheus-stack-and-argocd-23-how-to-remove-a-workaround -local helmapp = import "../../_templates/argo_helm_app.libsonnet"; -local argoapp = import "../../_templates/argo_app.libsonnet"; +local app = import "../../_templates/argocd_app.libsonnet"; local vars = { "version": "34.10.0", @@ -8,20 +7,20 @@ local vars = { }; [ -argoapp + { +app + { name:: "prometheus-crds", namespace:: vars.namespace, - repo:: "https://github.com/prometheus-community/helm-charts.git", path:: "charts/kube-prometheus-stack/crds/", + repo:: "https://github.com/prometheus-community/helm-charts.git", version:: "kube-prometheus-stack-" + vars.version, syncOptions:: ["CreateNamespace=true", "Replace=true"], sync_wave:: -1, }, -helmapp + { +app + { name:: "prometheus-grafana", namespace: vars.namespace, - repo:: "https://prometheus-community.github.io/helm-charts", chart:: "kube-prometheus-stack", + repo:: "https://prometheus-community.github.io/helm-charts", version:: vars.version, skipCrds:: true, values:: ||| diff --git a/k8s-manifests/reloader.jsonnet b/k8s-manifests/reloader.jsonnet index 7ae46a4..ffadca6 100644 --- a/k8s-manifests/reloader.jsonnet +++ b/k8s-manifests/reloader.jsonnet @@ -1,8 +1,8 @@ -local helmapp = import "../_templates/argo_helm_app.libsonnet"; +local app = import "../_templates/argocd_app.libsonnet"; [ -helmapp + { - name:: "reloader", +app + { + chart:: "reloader", repo:: "https://stakater.github.io/stakater-charts", version:: "v0.0.*", values:: |||