From ad74c53fdf3044fc99c2f497499135ce71cfaec8 Mon Sep 17 00:00:00 2001 From: Vegard Hagen Date: Fri, 7 Jul 2023 22:41:11 +0200 Subject: [PATCH] feat(infra): Use a single ApplicationSet instead of multiple Application manifests for infrastructure applications --- .gitignore | 33 -------------------------- infra/application-set.yaml | 36 +++++++++++++++++++++++++++++ infra/argocd.yaml | 22 ------------------ infra/cert-manager.yaml | 22 ------------------ infra/cilium.yaml | 22 ------------------ infra/dashboard.yaml | 22 ------------------ infra/dashboard/kustomization.yaml | 1 + infra/dashboard/namespace.yaml | 4 ++++ infra/metallb.yaml | 22 ------------------ infra/monitoring.yaml | 25 -------------------- infra/monitoring/kustomization.yaml | 1 + infra/monitoring/namespace.yaml | 4 ++++ infra/sealed-secrets.yaml | 22 ------------------ infra/traefik.yaml | 24 ------------------- infra/traefik/kustomization.yaml | 2 ++ infra/traefik/namespace.yaml | 4 ++++ 16 files changed, 52 insertions(+), 214 deletions(-) create mode 100644 infra/application-set.yaml delete mode 100644 infra/argocd.yaml delete mode 100644 infra/cert-manager.yaml delete mode 100644 infra/cilium.yaml delete mode 100644 infra/dashboard.yaml create mode 100644 infra/dashboard/namespace.yaml delete mode 100644 infra/metallb.yaml delete mode 100644 infra/monitoring.yaml create mode 100644 infra/monitoring/namespace.yaml delete mode 100644 infra/sealed-secrets.yaml delete mode 100644 infra/traefik.yaml create mode 100644 infra/traefik/namespace.yaml diff --git a/.gitignore b/.gitignore index 04454f9..a967792 100644 --- a/.gitignore +++ b/.gitignore @@ -1,35 +1,2 @@ -# Local .terraform directories -**/.terraform/* - -# .tfstate files -*.tfstate -*.tfstate.* - -# Crash log files -crash.log - -# Ignore any .tfvars files that are generated automatically for each Terraform run. Most -# .tfvars files are managed as part of configuration and so should be included in -# version control. -# -# example.tfvars - -# Ignore override files as they are usually used to override resources locally and so -# are not checked in -override.tf -override.tf.json -*_override.tf -*_override.tf.json - -# Include override files you do wish to add to version control using negated pattern -# -# !example_override.tf - -# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan -# example: *tfplan* - -.terraform.lock.hcl .idea -certs/ - charts/example \ No newline at end of file diff --git a/infra/application-set.yaml b/infra/application-set.yaml new file mode 100644 index 0000000..2af3d62 --- /dev/null +++ b/infra/application-set.yaml @@ -0,0 +1,36 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + name: infrastructure + namespace: argocd + labels: + dev.stonegarden: infrastructure +spec: + generators: + - git: + repoURL: https://github.com/vehagn/homelab + revision: HEAD + directories: + - path: infra/* + template: + metadata: + name: '{{ path.basename }}' + labels: + dev.stonegarden: infrastructure + finalizers: + - resources-finalizer.argocd.argoproj.io + spec: + project: infrastructure + source: + plugin: + name: kustomize-build-with-helm + repoURL: https://github.com/vehagn/homelab + targetRevision: HEAD + path: '{{ path }}' + destination: + name: in-cluster + namespace: argocd + syncPolicy: + automated: + selfHeal: true + prune: true \ No newline at end of file diff --git a/infra/argocd.yaml b/infra/argocd.yaml deleted file mode 100644 index 41e0913..0000000 --- a/infra/argocd.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: argoproj.io/v1alpha1 -kind: Application -metadata: - name: argocd - namespace: argocd - finalizers: - - resources-finalizer.argocd.argoproj.io -spec: - project: infrastructure - source: - path: infra/argocd - repoURL: https://github.com/vehagn/homelab - targetRevision: HEAD - destination: - namespace: argocd - name: in-cluster - syncPolicy: - automated: - selfHeal: true - prune: true - syncOptions: - - CreateNamespace=true diff --git a/infra/cert-manager.yaml b/infra/cert-manager.yaml deleted file mode 100644 index 0774f4a..0000000 --- a/infra/cert-manager.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: argoproj.io/v1alpha1 -kind: Application -metadata: - name: cert-manager - namespace: argocd - finalizers: - - resources-finalizer.argocd.argoproj.io -spec: - project: infrastructure - source: - path: infra/cert-manager - repoURL: https://github.com/vehagn/homelab - targetRevision: HEAD - destination: - name: in-cluster - namespace: cert-manager - syncPolicy: - automated: - selfHeal: true - prune: true - syncOptions: - - CreateNamespace=true diff --git a/infra/cilium.yaml b/infra/cilium.yaml deleted file mode 100644 index 6984109..0000000 --- a/infra/cilium.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: argoproj.io/v1alpha1 -kind: Application -metadata: - name: cilium - namespace: argocd - finalizers: - - resources-finalizer.argocd.argoproj.io -spec: - project: infrastructure - source: - plugin: - name: kustomize-build-with-helm - path: infra/cilium - repoURL: https://github.com/vehagn/homelab - targetRevision: HEAD - destination: - namespace: kube-system - name: in-cluster - syncPolicy: - automated: - selfHeal: true - prune: true \ No newline at end of file diff --git a/infra/dashboard.yaml b/infra/dashboard.yaml deleted file mode 100644 index b9e6623..0000000 --- a/infra/dashboard.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: argoproj.io/v1alpha1 -kind: Application -metadata: - name: dashboard - namespace: argocd - finalizers: - - resources-finalizer.argocd.argoproj.io -spec: - project: infrastructure - source: - path: infra/dashboard - repoURL: https://github.com/vehagn/homelab - targetRevision: HEAD - destination: - namespace: kubernetes-dashboard - name: in-cluster - syncPolicy: - automated: - selfHeal: true - prune: true - syncOptions: - - CreateNamespace=true diff --git a/infra/dashboard/kustomization.yaml b/infra/dashboard/kustomization.yaml index 64120b7..38528c9 100644 --- a/infra/dashboard/kustomization.yaml +++ b/infra/dashboard/kustomization.yaml @@ -3,6 +3,7 @@ kind: Kustomization namespace: kubernetes-dashboard resources: + - namespace.yaml - https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/alternative.yaml - traefik-forward-auth - ingress.yaml diff --git a/infra/dashboard/namespace.yaml b/infra/dashboard/namespace.yaml new file mode 100644 index 0000000..47783df --- /dev/null +++ b/infra/dashboard/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: kubernetes-dashboard \ No newline at end of file diff --git a/infra/metallb.yaml b/infra/metallb.yaml deleted file mode 100644 index 2d011db..0000000 --- a/infra/metallb.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: argoproj.io/v1alpha1 -kind: Application -metadata: - name: metallb - namespace: argocd - finalizers: - - resources-finalizer.argocd.argoproj.io -spec: - project: infrastructure - source: - path: infra/metallb - repoURL: https://github.com/vehagn/homelab - targetRevision: HEAD - destination: - namespace: metallb-system - name: in-cluster - syncPolicy: - automated: - selfHeal: true - prune: true - syncOptions: - - CreateNamespace=true diff --git a/infra/monitoring.yaml b/infra/monitoring.yaml deleted file mode 100644 index 3df6041..0000000 --- a/infra/monitoring.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: argoproj.io/v1alpha1 -kind: Application -metadata: - name: monitoring - namespace: argocd - finalizers: - - resources-finalizer.argocd.argoproj.io -spec: - project: infrastructure - source: - plugin: - name: kustomize-build-with-helm - path: infra/monitoring - repoURL: https://github.com/vehagn/homelab - targetRevision: HEAD - destination: - namespace: monitoring - name: in-cluster - syncPolicy: - automated: - selfHeal: true - prune: true - syncOptions: - - ServerSideApply=true - - CreateNamespace=true diff --git a/infra/monitoring/kustomization.yaml b/infra/monitoring/kustomization.yaml index 2dc6f8e..4b9cfc4 100644 --- a/infra/monitoring/kustomization.yaml +++ b/infra/monitoring/kustomization.yaml @@ -2,5 +2,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: + - namespace.yaml - kube-prometheus-stack.yaml - ingress-route.yaml \ No newline at end of file diff --git a/infra/monitoring/namespace.yaml b/infra/monitoring/namespace.yaml new file mode 100644 index 0000000..3335b6a --- /dev/null +++ b/infra/monitoring/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: monitoring \ No newline at end of file diff --git a/infra/sealed-secrets.yaml b/infra/sealed-secrets.yaml deleted file mode 100644 index a7a4d28..0000000 --- a/infra/sealed-secrets.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: argoproj.io/v1alpha1 -kind: Application -metadata: - name: sealed-secrets - namespace: argocd - finalizers: - - resources-finalizer.argocd.argoproj.io -spec: - project: infrastructure - source: - path: infra/sealed-secrets - repoURL: https://github.com/vehagn/homelab - targetRevision: HEAD - destination: - name: in-cluster - namespace: kube-system - syncPolicy: - automated: - selfHeal: true - prune: true - syncOptions: - - CreateNamespace=true diff --git a/infra/traefik.yaml b/infra/traefik.yaml deleted file mode 100644 index ba0036c..0000000 --- a/infra/traefik.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: argoproj.io/v1alpha1 -kind: Application -metadata: - name: traefik - namespace: argocd - finalizers: - - resources-finalizer.argocd.argoproj.io -spec: - project: infrastructure - source: - plugin: - name: kustomize-build-with-helm - path: infra/traefik - repoURL: https://github.com/vehagn/homelab - targetRevision: HEAD - destination: - namespace: traefik-system - name: in-cluster - syncPolicy: - automated: - selfHeal: true - prune: true - syncOptions: - - CreateNamespace=true diff --git a/infra/traefik/kustomization.yaml b/infra/traefik/kustomization.yaml index a1e3042..5b98669 100644 --- a/infra/traefik/kustomization.yaml +++ b/infra/traefik/kustomization.yaml @@ -3,6 +3,7 @@ kind: Kustomization namespace: traefik-system resources: + - namespace.yaml - storageClass.yaml - persistentVolume.yaml - traefik-forward-auth @@ -13,4 +14,5 @@ helmCharts: repo: https://helm.traefik.io/traefik version: 23.0.1 releaseName: "traefik" + includeCRDs: true valuesFile: values.yaml diff --git a/infra/traefik/namespace.yaml b/infra/traefik/namespace.yaml new file mode 100644 index 0000000..c5d4ae8 --- /dev/null +++ b/infra/traefik/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: traefik-system \ No newline at end of file