From f742250f159f73114e102cd492bac2c2eaf030ee Mon Sep 17 00:00:00 2001 From: JohnnyMastricht Date: Mon, 3 Oct 2022 12:18:38 +0300 Subject: [PATCH 01/10] add externalSecret functionality fix templating add initContainers functionality --- charts/benji/templates/cron-jobs.yaml | 10 ++++++++++ charts/benji/templates/maint-deployment.yaml | 10 ++++++++++ charts/benji/templates/secret.yaml | 2 ++ 3 files changed, 22 insertions(+) diff --git a/charts/benji/templates/cron-jobs.yaml b/charts/benji/templates/cron-jobs.yaml index e876a514..54538734 100644 --- a/charts/benji/templates/cron-jobs.yaml +++ b/charts/benji/templates/cron-jobs.yaml @@ -42,6 +42,10 @@ spec: serviceAccountName: {{ tuple $ "" | include "benji.fullname" }} dnsPolicy: ClusterFirstWithHostNet restartPolicy: Never +{{- if $.Values.benji.initContainers }} + initContainers: +{{ toYaml $.Values.benji.initContainers | indent 12 }} +{{- end }} containers: - name: benji image: "{{ $.Values.benji.image.registry }}/{{ $.Values.benji.image.repository }}:{{ $.Values.benji.image.tag }}" @@ -79,9 +83,15 @@ spec: {{- end }} hostNetwork: false volumes: + {{- if $.Values.benji.externalSecretConfig }} + - name: benji-config + secret: + secretName: {{ $.Values.benji.externalSecretConfig }} + {{- else }} - name: benji-config secret: secretName: {{ tuple $ "" | include "benji.fullname" }} + {{- end }} - name: tz-config hostPath: path: /usr/share/zoneinfo/{{ $.Values.timeZone }} diff --git a/charts/benji/templates/maint-deployment.yaml b/charts/benji/templates/maint-deployment.yaml index f93e435d..4ad2774b 100644 --- a/charts/benji/templates/maint-deployment.yaml +++ b/charts/benji/templates/maint-deployment.yaml @@ -27,6 +27,10 @@ spec: spec: serviceAccountName: {{ tuple . "" | include "benji.fullname" }} dnsPolicy: ClusterFirstWithHostNet +{{- if .Values.benji.initContainers }} + initContainers: +{{ toYaml .Values.benji.initContainers | indent 8 }} +{{- end }} containers: - name: benji image: "{{ .Values.benji.image.registry }}/{{ .Values.benji.image.repository }}:{{ .Values.benji.image.tag }}" @@ -62,9 +66,15 @@ spec: {{- end }} hostNetwork: false volumes: +{{- if $.Values.benji.externalSecretConfig }} + - name: benji-config + secret: + secretName: {{ $.Values.benji.externalSecretConfig }} +{{- else }} - name: benji-config secret: secretName: {{ tuple . "" | include "benji.fullname" }} +{{- end }} - name: tz-config hostPath: path: /usr/share/zoneinfo/{{ .Values.timeZone }} diff --git a/charts/benji/templates/secret.yaml b/charts/benji/templates/secret.yaml index 54405a58..2c8696b2 100644 --- a/charts/benji/templates/secret.yaml +++ b/charts/benji/templates/secret.yaml @@ -1,3 +1,4 @@ +{{ if not .Values.benji.externalSecretConfig }} --- apiVersion: v1 kind: Secret @@ -10,3 +11,4 @@ metadata: app.kubernetes.io/managed-by: {{ .Release.Service }} data: benji.yaml: {{ printf "%s\n" (.Values.benji.configuration | toYaml) | b64enc }} +{{ end }} From 149f1da6d227bcca48931238d09bd43fef1efb11 Mon Sep 17 00:00:00 2001 From: JohnnyMastricht Date: Mon, 3 Oct 2022 13:07:01 +0300 Subject: [PATCH 02/10] add configMap for ceph configuration add secret for ceph configuration adjust values --- charts/benji-k8s/templates/configmap.yaml | 16 ++++++++++++++++ charts/benji/templates/_helpers.tpl | 19 +++++++++++++++++++ charts/benji/templates/secret.yaml | 18 ++++++++++++++++++ charts/benji/values.yaml | 6 ++++++ 4 files changed, 59 insertions(+) create mode 100644 charts/benji-k8s/templates/configmap.yaml diff --git a/charts/benji-k8s/templates/configmap.yaml b/charts/benji-k8s/templates/configmap.yaml new file mode 100644 index 00000000..320a603e --- /dev/null +++ b/charts/benji-k8s/templates/configmap.yaml @@ -0,0 +1,16 @@ +{{- if .Values.ceph.enabled }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.ceph.configMapName }} + labels: + app.kubernetes.io/name: {{ include "benji.name" . }} + helm.sh/chart: {{ include "benji.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/component: benji + app.kubernetes.io/managed-by: {{ .Release.Service }} +data: + ceph.conf: | +{{ include "benji.ceph-conf" . | indent 4 }} +{{- end }} diff --git a/charts/benji/templates/_helpers.tpl b/charts/benji/templates/_helpers.tpl index 53a2e1c1..209b5bb4 100644 --- a/charts/benji/templates/_helpers.tpl +++ b/charts/benji/templates/_helpers.tpl @@ -43,3 +43,22 @@ Create hostname:port pair pointing to the Prometheus pushgateway {{- define "benji.pushgateway" -}} {{- printf "%s-%s" .Release.Name .Values.pushgateway.nameOverride | trunc 63 | trimSuffix "-" -}}:{{ .Values.pushgateway.service.port }} {{- end -}} + +{{/* +ceph conf +*/}} +{{- define "benji.ceph-conf" -}} +[global] +mon_host = {{ .Values.ceph.mon_hosts }} + +[client.admin] +keyring = /etc/ceph/keyring +{{ end -}} + +{{/* +ceph client admin keyring +*/}} +{{- define "benji.ceph-keyring" -}} +[client.admin] +key = {{ .Values.ceph.key }} +{{ end -}} diff --git a/charts/benji/templates/secret.yaml b/charts/benji/templates/secret.yaml index 2c8696b2..7b9566f0 100644 --- a/charts/benji/templates/secret.yaml +++ b/charts/benji/templates/secret.yaml @@ -12,3 +12,21 @@ metadata: data: benji.yaml: {{ printf "%s\n" (.Values.benji.configuration | toYaml) | b64enc }} {{ end }} + +{{- if .Values.ceph.createKeyringSecret }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: ceph-keyring-secret + labels: + app.kubernetes.io/name: {{ include "benji.name" . }} + helm.sh/chart: {{ include "benji.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/component: benji + app.kubernetes.io/managed-by: {{ .Release.Service }} +type: Opaque +data: + keyring: | +{{ include "benji.ceph-keyring" . | b64enc | indent 4 }} +{{- end }} diff --git a/charts/benji/values.yaml b/charts/benji/values.yaml index 6b9f6921..8bf06ef7 100644 --- a/charts/benji/values.yaml +++ b/charts/benji/values.yaml @@ -17,6 +17,10 @@ benji: affinity: {} + initContainers: [] +## insert a secret name here that contains your configuration, otherwise the below configuration is used + externalSecretConfig: false + configuration: configurationVersion: '1' databaseEngine: sqlite:////tmp/benji.sqlite @@ -177,3 +181,5 @@ pushgateway: nameOverride: pushgateway service: port: 9091 + +ceph: {} From a479b7682df290d0df29e941d213818515d46482 Mon Sep 17 00:00:00 2001 From: JohnnyMastricht Date: Mon, 3 Oct 2022 13:24:37 +0300 Subject: [PATCH 03/10] align secretName --- charts/benji/templates/secret.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/benji/templates/secret.yaml b/charts/benji/templates/secret.yaml index 7b9566f0..aa31a752 100644 --- a/charts/benji/templates/secret.yaml +++ b/charts/benji/templates/secret.yaml @@ -18,7 +18,7 @@ data: apiVersion: v1 kind: Secret metadata: - name: ceph-keyring-secret + name: benji-ceph-keyring labels: app.kubernetes.io/name: {{ include "benji.name" . }} helm.sh/chart: {{ include "benji.chart" . }} From 79a7e26954e5fe84c38a5fe5e10d81cf05b0e12f Mon Sep 17 00:00:00 2001 From: Vladyslav Riabyk Date: Tue, 18 Oct 2022 11:59:35 +0300 Subject: [PATCH 04/10] small fix after rebase --- charts/{benji-k8s => benji}/templates/configmap.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename charts/{benji-k8s => benji}/templates/configmap.yaml (100%) diff --git a/charts/benji-k8s/templates/configmap.yaml b/charts/benji/templates/configmap.yaml similarity index 100% rename from charts/benji-k8s/templates/configmap.yaml rename to charts/benji/templates/configmap.yaml From d2bb3ba87a97f985f70f026812d9b7cbf425f448 Mon Sep 17 00:00:00 2001 From: Vladyslav Riabyk Date: Tue, 18 Oct 2022 12:50:46 +0300 Subject: [PATCH 05/10] Add chart dependencies folder to gitignore, add Charts.lock required for ArgoCD --- .gitignore | 1 + charts/benji/Chart.lock | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 charts/benji/Chart.lock diff --git a/.gitignore b/.gitignore index 1293ac74..054609b4 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ dist .b2-account-info* tests-scratch .mypy_cache +charts/benji/charts/ diff --git a/charts/benji/Chart.lock b/charts/benji/Chart.lock new file mode 100644 index 00000000..ba0c345b --- /dev/null +++ b/charts/benji/Chart.lock @@ -0,0 +1,9 @@ +dependencies: +- name: postgresql + repository: https://charts.bitnami.com/bitnami + version: 11.9.10 +- name: prometheus-pushgateway + repository: https://prometheus-community.github.io/helm-charts + version: 1.20.0 +digest: sha256:172adbeff0fa5c2bf605278fa79da003fc406fe84bdcd6b22311a5faea48c448 +generated: "2022-10-18T12:46:21.995138612+03:00" From 612273e61304d82d008aeea74039370126ea5610 Mon Sep 17 00:00:00 2001 From: JohnnyMastricht Date: Thu, 24 Nov 2022 21:17:18 +0200 Subject: [PATCH 06/10] delete Chart.lock --- charts/benji/Chart.lock | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 charts/benji/Chart.lock diff --git a/charts/benji/Chart.lock b/charts/benji/Chart.lock deleted file mode 100644 index ba0c345b..00000000 --- a/charts/benji/Chart.lock +++ /dev/null @@ -1,9 +0,0 @@ -dependencies: -- name: postgresql - repository: https://charts.bitnami.com/bitnami - version: 11.9.10 -- name: prometheus-pushgateway - repository: https://prometheus-community.github.io/helm-charts - version: 1.20.0 -digest: sha256:172adbeff0fa5c2bf605278fa79da003fc406fe84bdcd6b22311a5faea48c448 -generated: "2022-10-18T12:46:21.995138612+03:00" From 86ab803698c388293f5b6bd9039fc04d1bb46476 Mon Sep 17 00:00:00 2001 From: JohnnyMastricht Date: Mon, 28 Nov 2022 10:25:19 +0200 Subject: [PATCH 07/10] change externalSecret default naming --- charts/benji/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/benji/values.yaml b/charts/benji/values.yaml index 8bf06ef7..a785cd2d 100644 --- a/charts/benji/values.yaml +++ b/charts/benji/values.yaml @@ -19,7 +19,7 @@ benji: initContainers: [] ## insert a secret name here that contains your configuration, otherwise the below configuration is used - externalSecretConfig: false + externalSecretConfig: "" configuration: configurationVersion: '1' From 1c7ab40a8ef4335452f4d1eb32717defd8b2b640 Mon Sep 17 00:00:00 2001 From: JohnnyMastricht Date: Fri, 24 Mar 2023 15:48:04 +0100 Subject: [PATCH 08/10] delete unnecessary block --- charts/benji/templates/_helpers.tpl | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/charts/benji/templates/_helpers.tpl b/charts/benji/templates/_helpers.tpl index 209b5bb4..365a9ff7 100644 --- a/charts/benji/templates/_helpers.tpl +++ b/charts/benji/templates/_helpers.tpl @@ -44,17 +44,6 @@ Create hostname:port pair pointing to the Prometheus pushgateway {{- printf "%s-%s" .Release.Name .Values.pushgateway.nameOverride | trunc 63 | trimSuffix "-" -}}:{{ .Values.pushgateway.service.port }} {{- end -}} -{{/* -ceph conf -*/}} -{{- define "benji.ceph-conf" -}} -[global] -mon_host = {{ .Values.ceph.mon_hosts }} - -[client.admin] -keyring = /etc/ceph/keyring -{{ end -}} - {{/* ceph client admin keyring */}} From a47cdf64a0cc38babd3b3f90631c6ba8a09ddf1b Mon Sep 17 00:00:00 2001 From: crabique Date: Tue, 28 Mar 2023 16:09:40 +0300 Subject: [PATCH 09/10] add configurable ceph users --- charts/benji/templates/_helpers.tpl | 15 +++++++++++++-- charts/benji/templates/cron-jobs.yaml | 4 ++++ charts/benji/templates/maint-deployment.yaml | 4 ++++ charts/benji/values.yaml | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/charts/benji/templates/_helpers.tpl b/charts/benji/templates/_helpers.tpl index 365a9ff7..85d220e3 100644 --- a/charts/benji/templates/_helpers.tpl +++ b/charts/benji/templates/_helpers.tpl @@ -45,9 +45,20 @@ Create hostname:port pair pointing to the Prometheus pushgateway {{- end -}} {{/* -ceph client admin keyring +ceph conf +*/}} +{{- define "benji.ceph-conf" -}} +[global] +mon_host = {{ .Values.ceph.mon_hosts }} + +[client.{{ .Values.ceph.user | default "admin" }}] +keyring = /etc/ceph/keyring +{{ end -}} + +{{/* +ceph client keyring */}} {{- define "benji.ceph-keyring" -}} -[client.admin] +[client.{{ .Values.ceph.user | default "admin" }}] key = {{ .Values.ceph.key }} {{ end -}} diff --git a/charts/benji/templates/cron-jobs.yaml b/charts/benji/templates/cron-jobs.yaml index 54538734..6810461c 100644 --- a/charts/benji/templates/cron-jobs.yaml +++ b/charts/benji/templates/cron-jobs.yaml @@ -66,6 +66,10 @@ spec: {{- if $.Values.pushgateway.enabled }} - name: PROM_PUSH_GATEWAY value: "{{ include "benji.pushgateway" $ }}" +{{- end }} +{{- with $.Values.ceph.user }} + - name: CEPH_ARGS + value: "--name client.{{ . }}" {{- end }} - name: TZ value: "{{ $.Values.timeZone }}" diff --git a/charts/benji/templates/maint-deployment.yaml b/charts/benji/templates/maint-deployment.yaml index 4ad2774b..2e8692a8 100644 --- a/charts/benji/templates/maint-deployment.yaml +++ b/charts/benji/templates/maint-deployment.yaml @@ -49,6 +49,10 @@ spec: {{- if .Values.pushgateway.enabled }} - name: PROM_PUSH_GATEWAY value: "{{ include "benji.pushgateway" $ }}" +{{- end }} +{{- with .Values.ceph.user }} + - name: CEPH_ARGS + value: "--name client.{{ . }}" {{- end }} - name: TZ value: "{{ .Values.timeZone }}" diff --git a/charts/benji/values.yaml b/charts/benji/values.yaml index a785cd2d..4d880fb9 100644 --- a/charts/benji/values.yaml +++ b/charts/benji/values.yaml @@ -181,5 +181,5 @@ pushgateway: nameOverride: pushgateway service: port: 9091 - + ceph: {} From 0c93842656d3e37a69d392cf5b3f99b3073e9a16 Mon Sep 17 00:00:00 2001 From: Vladyslav Riabyk Date: Thu, 6 Apr 2023 17:35:07 +0300 Subject: [PATCH 10/10] adding ability to change command --- charts/benji/templates/maint-deployment.yaml | 4 ++++ charts/benji/values.yaml | 3 +++ 2 files changed, 7 insertions(+) diff --git a/charts/benji/templates/maint-deployment.yaml b/charts/benji/templates/maint-deployment.yaml index 2e8692a8..62e92056 100644 --- a/charts/benji/templates/maint-deployment.yaml +++ b/charts/benji/templates/maint-deployment.yaml @@ -35,6 +35,10 @@ spec: - name: benji image: "{{ .Values.benji.image.registry }}/{{ .Values.benji.image.repository }}:{{ .Values.benji.image.tag }}" imagePullPolicy: {{ .Values.benji.image.pullPolicy }} +{{- with .Values.benji.command }} + command: + {{- toYaml . | nindent 12 }} +{{- end }} securityContext: privileged: true env: diff --git a/charts/benji/values.yaml b/charts/benji/values.yaml index 4d880fb9..eae1b83b 100644 --- a/charts/benji/values.yaml +++ b/charts/benji/values.yaml @@ -18,6 +18,9 @@ benji: affinity: {} initContainers: [] + + command: [] + ## insert a secret name here that contains your configuration, otherwise the below configuration is used externalSecretConfig: ""