From e249df8693d6d0ecd2b7df4511ab60859d6feb3d Mon Sep 17 00:00:00 2001 From: Morten Olsen Date: Wed, 3 Dec 2025 20:16:02 +0100 Subject: [PATCH] add shared resources --- foundation/root/templates/project.yaml | 2 +- shared/charts/postgres-cluster/Chart.yaml | 3 ++ .../postgres-cluster/templates/cluster.yaml | 10 +++++ shared/charts/postgres-cluster/values.yaml | 1 + shared/root/Chart.yaml | 6 +++ shared/root/templates/applicationset.yaml | 39 +++++++++++++++++++ shared/root/templates/project.yaml | 17 ++++++++ shared/root/values.yaml | 8 ++++ 8 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 shared/charts/postgres-cluster/Chart.yaml create mode 100644 shared/charts/postgres-cluster/templates/cluster.yaml create mode 100644 shared/charts/postgres-cluster/values.yaml create mode 100644 shared/root/Chart.yaml create mode 100644 shared/root/templates/applicationset.yaml create mode 100644 shared/root/templates/project.yaml create mode 100644 shared/root/values.yaml diff --git a/foundation/root/templates/project.yaml b/foundation/root/templates/project.yaml index f56e01d..3fe6753 100644 --- a/foundation/root/templates/project.yaml +++ b/foundation/root/templates/project.yaml @@ -8,7 +8,7 @@ spec: sourceRepos: - "*" destinations: - - namespace: foundation + - namespace: "{{ .Values.project }}" server: https://kubernetes.default.svc - namespace: argocd server: https://kubernetes.default.svc diff --git a/shared/charts/postgres-cluster/Chart.yaml b/shared/charts/postgres-cluster/Chart.yaml new file mode 100644 index 0000000..019aae1 --- /dev/null +++ b/shared/charts/postgres-cluster/Chart.yaml @@ -0,0 +1,3 @@ +apiVersion: v2 +version: 1.0.0 +name: postgres-cluster diff --git a/shared/charts/postgres-cluster/templates/cluster.yaml b/shared/charts/postgres-cluster/templates/cluster.yaml new file mode 100644 index 0000000..6f8e4d1 --- /dev/null +++ b/shared/charts/postgres-cluster/templates/cluster.yaml @@ -0,0 +1,10 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: "{{ .Release.Name }}" + namespace: "{{ .Release.Namespace }}" +spec: + instances: 1 + storage: + storageClass: "{{ .Values.globals.storageClass }}" + size: 2Gi diff --git a/shared/charts/postgres-cluster/values.yaml b/shared/charts/postgres-cluster/values.yaml new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/shared/charts/postgres-cluster/values.yaml @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/shared/root/Chart.yaml b/shared/root/Chart.yaml new file mode 100644 index 0000000..11e61b0 --- /dev/null +++ b/shared/root/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: shared +description: A Helm chart for the shared resources of the homelab +type: application +version: 0.1.0 +appVersion: "1.0.0" diff --git a/shared/root/templates/applicationset.yaml b/shared/root/templates/applicationset.yaml new file mode 100644 index 0000000..7697147 --- /dev/null +++ b/shared/root/templates/applicationset.yaml @@ -0,0 +1,39 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + name: shared + namespace: argocd +spec: + generators: + - git: + repoURL: {{ .Values.repoURL }} + revision: {{ .Values.targetRevision }} + directories: + - path: {{ .Values.path }}/* + - path: {{ .Values.path }}/*{{ .Values.exclude }} + exclude: true + template: + metadata: + name: '{{`{{path.basename}}`}}' + spec: + project: {{ .Values.project }} + source: + repoURL: {{ .Values.repoURL }} + targetRevision: {{ .Values.targetRevision }} + path: '{{`{{path}}`}}' + helm: + valueFiles: + - values.yaml + values: | + globals: + timezone: {{ .Values.globals.timezone }} + storageClass: {{ .Values.globals.storageClass }} + destination: + server: https://kubernetes.default.svc + namespace: "{{ .Values.project }}" + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=true diff --git a/shared/root/templates/project.yaml b/shared/root/templates/project.yaml new file mode 100644 index 0000000..3fe6753 --- /dev/null +++ b/shared/root/templates/project.yaml @@ -0,0 +1,17 @@ +apiVersion: argoproj.io/v1alpha1 +kind: AppProject +metadata: + name: "{{ .Values.project }}" + namespace: argocd +spec: + description: "Project for homelab apps" + sourceRepos: + - "*" + destinations: + - namespace: "{{ .Values.project }}" + server: https://kubernetes.default.svc + - namespace: argocd + server: https://kubernetes.default.svc + clusterResourceWhitelist: + - group: "*" + kind: "*" diff --git a/shared/root/values.yaml b/shared/root/values.yaml new file mode 100644 index 0000000..2a1684d --- /dev/null +++ b/shared/root/values.yaml @@ -0,0 +1,8 @@ +repoURL: "https://github.com/morten-olsen/homelab-apps" +targetRevision: "main" +path: "shared/charts" +exclude: "*.disabled" +project: "shared" +globals: + timezone: Europe/Amsterdam + storageClass: prod \ No newline at end of file