From 2f8a4145ed6a22d412b1be43391e747518d5e99a Mon Sep 17 00:00:00 2001 From: Chris Werner Rau Date: Tue, 2 Jul 2024 12:26:01 +0200 Subject: [PATCH] feat(base-cluster): add kube-janitor (#1011) --- charts/base-cluster/Chart.lock | 6 ++-- charts/base-cluster/Chart.yaml | 2 +- .../templates/global/kube-janitor.yaml | 30 +++++++++++++++++++ charts/base-cluster/values.schema.json | 11 ++++++- charts/base-cluster/values.yaml | 11 +++++++ 5 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 charts/base-cluster/templates/global/kube-janitor.yaml diff --git a/charts/base-cluster/Chart.lock b/charts/base-cluster/Chart.lock index 2692931b1..cd132f8ae 100644 --- a/charts/base-cluster/Chart.lock +++ b/charts/base-cluster/Chart.lock @@ -1,6 +1,6 @@ dependencies: - name: common repository: oci://ghcr.io/teutonet/teutonet-helm-charts - version: 1.0.0 -digest: sha256:acfa022eb3ff1b32622813ee173a127c23c729abb6fe8235795b668bb496ed2e -generated: "2024-04-12T13:36:20.75023109+02:00" + version: 1.2.0 +digest: sha256:62ef92fb03b60b1bf481b96b8b856f3b3156c10cc50a50e3604c8b679ef71497 +generated: "2024-07-01T11:48:12.942337506+02:00" diff --git a/charts/base-cluster/Chart.yaml b/charts/base-cluster/Chart.yaml index 1a89b0192..c6fb61690 100644 --- a/charts/base-cluster/Chart.yaml +++ b/charts/base-cluster/Chart.yaml @@ -16,7 +16,7 @@ home: https://teuto.net description: A common base for every kubernetes cluster dependencies: - name: common - version: 1.0.0 + version: 1.2.0 repository: oci://ghcr.io/teutonet/teutonet-helm-charts annotations: artifacthub.io/images: | diff --git a/charts/base-cluster/templates/global/kube-janitor.yaml b/charts/base-cluster/templates/global/kube-janitor.yaml new file mode 100644 index 000000000..62ff5eda5 --- /dev/null +++ b/charts/base-cluster/templates/global/kube-janitor.yaml @@ -0,0 +1,30 @@ +{{- if dig "kube-janitor" "enabled" false .Values.AsMap -}} +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + name: kube-janitor + namespace: kube-system + labels: {{- include "common.labels.standard" $ | nindent 4 }} + app.kubernetes.io/component: kube-janitor +spec: + chart: + spec: {{- include "base-cluster.helm.chartSpec" (dict "repo" "kube-janitor" "chart" "kube-janitor" "context" $) | nindent 6 }} + interval: 1h + driftDetection: + mode: enabled + values: + priorityClassName: cluster-components + {{- $image := dict -}} + {{- if .Values.global.imageRegistry -}} + {{- $image = set $image "repository" (printf "%s/hjacobs/kube-janitor" $.Values.global.imageRegistry) -}} + {{- end }} + {{- with dig "kube-janitor" "charts" "kube-janitor" "tag" "" .Values.global.helmRepositories -}} + {{- $image = set $image "tag" . -}} + {{- end }} + {{- with $image }} + image: {{- toYaml $image | nindent 6 }} + {{- end }} + resources: + limits: + memory: 1Gi +{{- end -}} diff --git a/charts/base-cluster/values.schema.json b/charts/base-cluster/values.schema.json index 9e7f0a95a..e2efc8860 100644 --- a/charts/base-cluster/values.schema.json +++ b/charts/base-cluster/values.schema.json @@ -818,7 +818,7 @@ }, "additionalProperties": false }, - "sidecar": { + "sidecar": { "type": "object", "properties": { "resourcesPreset": { @@ -1552,6 +1552,15 @@ ], "additionalProperties": false }, + "kube-janitor": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + } + }, + "additionalProperties": false + }, "common": { "type": "object", "description": "Values for sub-chart" diff --git a/charts/base-cluster/values.yaml b/charts/base-cluster/values.yaml index 600eb09d3..47edd7eee 100644 --- a/charts/base-cluster/values.yaml +++ b/charts/base-cluster/values.yaml @@ -172,6 +172,14 @@ global: charts: opentelemetry-collector: 0.x.x condition: "{{ and .Values.monitoring.tracing.enabled .Values.monitoring.prometheus.enabled }}" + kube-janitor: + url: https://codeberg.org/hjacobs/kube-janitor + charts: + kube-janitor: + path: unsupported/helm + tag: 23.7.0 + type: git + condition: '{{ dig "kube-janitor" "enabled" false .Values.AsMap }}' authentication: grafana: authenticationPath: /protocol/openid-connect/auth @@ -436,3 +444,6 @@ backup: limits: cpu: 500m memory: 500Mi + +kube-janitor: + enabled: false