From c24202074481d057e1667b88800d051d6925bf93 Mon Sep 17 00:00:00 2001 From: Nabeel Saabna <48175656+nabeelsaabna@users.noreply.github.com> Date: Thu, 18 Jan 2024 18:34:46 +0200 Subject: [PATCH] add PostgreSQL to chart (#424) --- .../templates/deployment-postgresql.yaml | 41 +++++++++++++++++++ .../templates/deployment-server.yaml | 27 +++++++++++- .../templates/deployment-worker.yaml | 6 ++- .../templates/srv-database.yaml | 22 ++++++++++ .../{service.yaml => srv-server.yaml} | 4 +- helm-charts/mend-renovate-ee/values.yaml | 26 +++++++++++- 6 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 helm-charts/mend-renovate-ee/templates/deployment-postgresql.yaml create mode 100644 helm-charts/mend-renovate-ee/templates/srv-database.yaml rename helm-charts/mend-renovate-ee/templates/{service.yaml => srv-server.yaml} (86%) diff --git a/helm-charts/mend-renovate-ee/templates/deployment-postgresql.yaml b/helm-charts/mend-renovate-ee/templates/deployment-postgresql.yaml new file mode 100644 index 00000000..9e2a0504 --- /dev/null +++ b/helm-charts/mend-renovate-ee/templates/deployment-postgresql.yaml @@ -0,0 +1,41 @@ +{{- if and .Values.postgresql.enabled .Values.postgresql.development }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "mend-renovate.fullname" . }}-database + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: {{ include "mend-renovate.name" . }} + helm.sh/chart: {{ include "mend-renovate.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: {{ include "mend-renovate.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app: {{ include "mend-renovate.name" . }}-database + strategy: + type: Recreate + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "mend-renovate.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app: {{ include "mend-renovate.name" . }}-database + spec: + containers: + - name: {{ .Chart.Name }}-postgresql + image: "{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}" + imagePullPolicy: {{ .Values.postgresql.image.pullPolicy }} + env: + - name: POSTGRES_USER + value: {{ .Values.postgresql.user | quote }} + - name: POSTGRES_PASSWORD + value: {{ .Values.postgresql.password | quote }} + ports: + - name: ee-db + containerPort: {{ .Values.postgresql.port }} + protocol: TCP +{{- end }} \ No newline at end of file diff --git a/helm-charts/mend-renovate-ee/templates/deployment-server.yaml b/helm-charts/mend-renovate-ee/templates/deployment-server.yaml index 7b174d80..235873a5 100644 --- a/helm-charts/mend-renovate-ee/templates/deployment-server.yaml +++ b/helm-charts/mend-renovate-ee/templates/deployment-server.yaml @@ -9,7 +9,7 @@ metadata: app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} spec: - replicas: 1 + replicas: {{ .Values.renovateServer.replicas }} selector: matchLabels: app.kubernetes.io/name: {{ include "mend-renovate.name" . }} @@ -46,6 +46,27 @@ spec: {{- with .Values.renovateServer.extraEnvVars }} {{- toYaml . | nindent 12 }} {{- end }} + + {{- if .Values.postgresql.enabled }} + - name: MEND_RNV_DATA_HANDLER_TYPE + value: postgresql + - name: PGDATABASE + value: {{ .Values.postgresql.database | quote }} + - name: PGUSER + value: {{ .Values.postgresql.user | quote }} + - name: PGPASSWORD + value: {{ .Values.postgresql.password | quote }} + - name: PGPORT + value: {{ .Values.postgresql.port | quote }} + {{- end }} + {{- if and .Values.postgresql.enabled .Values.postgresql.development }} + - name: PGHOST + value: "{{ include "mend-renovate.fullname" . }}-srv-database" + {{- else if .Values.postgresql.enabled }} + - name: PGHOST + value: {{ .Values.postgresql.host | quote }} + {{- end }} + {{- if .Values.license.mendRnvAcceptTos }} - name: MEND_RNV_ACCEPT_TOS value: {{ .Values.license.mendRnvAcceptTos | quote }} @@ -125,6 +146,10 @@ spec: - name: LOG_LEVEL value: {{ .Values.renovateServer.logLevel | quote }} {{- end }} + {{- if .Values.renovateServer.logFormat }} + - name: LOG_FORMAT + value: {{ .Values.renovateServer.logFormat | quote }} + {{- end }} {{- if .Values.renovateServer.mendRnvAdminApiEnabled }} - name: MEND_RNV_ADMIN_API_ENABLED value: {{ .Values.renovateServer.mendRnvAdminApiEnabled | quote }} diff --git a/helm-charts/mend-renovate-ee/templates/deployment-worker.yaml b/helm-charts/mend-renovate-ee/templates/deployment-worker.yaml index 6ede2cd1..656b69c7 100644 --- a/helm-charts/mend-renovate-ee/templates/deployment-worker.yaml +++ b/helm-charts/mend-renovate-ee/templates/deployment-worker.yaml @@ -42,7 +42,7 @@ spec: {{- toYaml . | nindent 12 }} {{- end }} - name: MEND_RNV_SERVER_HOSTNAME - value: "http://{{ include "mend-renovate.fullname" . }}" + value: "http://{{ include "mend-renovate.fullname" . }}-srv-server" {{- if or .Values.renovateServer.mendRnvServerApiSecret .Values.renovateServer.existingSecret }} - name: MEND_RNV_SERVER_API_SECRET valueFrom: @@ -110,6 +110,10 @@ spec: - name: LOG_LEVEL value: {{ .Values.renovateWorker.logLevel | quote }} {{- end }} + {{- if .Values.renovateWorker.logFormat }} + - name: LOG_FORMAT + value: {{ .Values.renovateWorker.logFormat | quote }} + {{- end }} resources: {{- toYaml .Values.renovateWorker.resources | nindent 12 }} volumeMounts: diff --git a/helm-charts/mend-renovate-ee/templates/srv-database.yaml b/helm-charts/mend-renovate-ee/templates/srv-database.yaml new file mode 100644 index 00000000..4b929190 --- /dev/null +++ b/helm-charts/mend-renovate-ee/templates/srv-database.yaml @@ -0,0 +1,22 @@ +{{- if and .Values.postgresql.enabled .Values.postgresql.development }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "mend-renovate.fullname" . }}-srv-database + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: {{ include "mend-renovate.name" . }} + helm.sh/chart: {{ include "mend-renovate.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + type: ClusterIP + ports: + - protocol: TCP + port: {{ .Values.postgresql.port }} + targetPort: {{ .Values.postgresql.port }} + selector: + app.kubernetes.io/name: {{ include "mend-renovate.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app: {{ include "mend-renovate.name" . }}-database +{{- end }} \ No newline at end of file diff --git a/helm-charts/mend-renovate-ee/templates/service.yaml b/helm-charts/mend-renovate-ee/templates/srv-server.yaml similarity index 86% rename from helm-charts/mend-renovate-ee/templates/service.yaml rename to helm-charts/mend-renovate-ee/templates/srv-server.yaml index b21c6e0a..2124eac1 100644 --- a/helm-charts/mend-renovate-ee/templates/service.yaml +++ b/helm-charts/mend-renovate-ee/templates/srv-server.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "mend-renovate.fullname" . }} + name: {{ include "mend-renovate.fullname" . }}-srv-server namespace: {{ .Release.Namespace }} labels: app.kubernetes.io/name: {{ include "mend-renovate.name" . }} @@ -22,4 +22,4 @@ spec: selector: app.kubernetes.io/name: {{ include "mend-renovate.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} - app: {{ .Chart.Name }}-server + app: {{ include "mend-renovate.name" . }}-server diff --git a/helm-charts/mend-renovate-ee/values.yaml b/helm-charts/mend-renovate-ee/values.yaml index 775da7d5..d19e57cb 100644 --- a/helm-charts/mend-renovate-ee/values.yaml +++ b/helm-charts/mend-renovate-ee/values.yaml @@ -1,5 +1,5 @@ -nameOverride: "" -fullnameOverride: "" +nameOverride: "mend-renovate" +fullnameOverride: "mend-renovate" license: # Set this to the key you received by email. @@ -16,12 +16,30 @@ license: # mendRnvLicenseKey: existingSecret: +postgresql: + # if to use PostgreSQL, if set to 'false' SQLite will be used instead + enabled: + host: + port: + database: + user: + password: + + # used for development purposes + development: {} + # repository: postgres + # tag: 16.1-alpine3.17 + # pullPolicy: IfNotPresent + renovateServer: image: repository: ghcr.io/mend/renovate-ee-server tag: 6.8.0 pullPolicy: IfNotPresent + # Number of renovate-ee-server (for SQLite only 1 replica is allowed) + replicas: 1 + # Additional server env vars extraEnvVars: [] @@ -78,6 +96,8 @@ renovateServer: # Set log level, defaults to 'info'. Allowed values: fatal, error, warn, info, debug, trace logLevel: info + # Set log format, defaults to pretty format. Allowed values: undefined or 'json' + logFormat: json resources: { } @@ -174,6 +194,8 @@ renovateWorker: # Set log level, defaults to 'info'. Allowed values: fatal, error, warn, info, debug, trace logLevel: info + # Set log format, defaults to pretty format. Allowed values: undefined or 'json' + logFormat: json # Self-hosted renovate configuration file, will be mounted as a config map config: |