Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Resolves qameta/infra#85
Browse files Browse the repository at this point in the history
  • Loading branch information
a-ryoo committed Sep 21, 2023
1 parent b51b3c5 commit 64c4570
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
password: ${{ secrets.ARTIFACTORY_PASS }}
repoName: allure-testops
chart: charts/allure-testops
version: 2.0.4
version: 2.1.0
2 changes: 1 addition & 1 deletion charts/allure-testops/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: allure-testops
version: 2.0.4
version: 2.1.0
appVersion: 4.20.3

description: Allure TestOps
Expand Down
22 changes: 19 additions & 3 deletions charts/allure-testops/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,23 @@
{{- if .Values.postgresql.enabled }}
{{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- print .Values.postgresql.external.uaaHost }}
{{- if .Values.postgresql.external.pgbouncer.enabled }}
{{- print "localhost"}}
{{- else }}
{{- print .Values.postgresql.external.uaaHost }}
{{- end }}
{{- end }}
{{- end }}

{{- define "uaaDBPort" }}
{{- if .Values.postgresql.enabled }}
{{- printf "%.f" .Values.postgresql.primary.service.ports.postgresql }}
{{- else }}
{{- if .Values.postgresql.external.pgbouncer.enabled }}
{{- print "5432"}}
{{- else }}
{{- print .Values.postgresql.external.uaaPort }}
{{- end }}
{{- end }}
{{- end }}
{{- define "uaaDBName" }}
Expand All @@ -112,15 +120,23 @@
{{- if .Values.postgresql.enabled }}
{{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- print .Values.postgresql.external.reportHost }}
{{- if .Values.postgresql.external.pgbouncer.enabled }}
{{- print "localhost"}}
{{- else }}
{{- print .Values.postgresql.external.reportHost }}
{{- end }}
{{- end }}
{{- end }}

{{- define "reportDBPort" }}
{{- if .Values.postgresql.enabled }}
{{- printf "%.f" .Values.postgresql.primary.service.ports.postgresql }}
{{- else }}
{{- print .Values.postgresql.external.reportPort}}
{{- if .Values.postgresql.external.pgbouncer.enabled }}
{{- print "5432" }}
{{- else }}
{{- print .Values.postgresql.external.reportPort}}
{{- end }}
{{- end }}
{{- end }}

Expand Down
43 changes: 43 additions & 0 deletions charts/allure-testops/templates/allure/report-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@ spec:
resources:
{{ toYaml . | indent 12 }}
{{- end }}
{{- if .Values.postgresql.external.pgbouncer.enabled }}
command: [ 'sh', '-c',
'until pg_isready -h {{ .Values.postgresql.external.reportHost }} -p {{ .Values.postgresql.external.reportPort }};
do echo waiting for database; sleep 2; done;' ]
{{- else }}
command: [ 'sh', '-c',
'until pg_isready -h {{ template "reportDBHost" . }} -p {{ template "reportDBPort" . }};
do echo waiting for database; sleep 2; done;' ]
{{- end }}
{{- $secret_name := include "allure-testops.secret.name" . }}
containers:
- name: {{ template "allure-testops.report.fullname" . }}
Expand Down Expand Up @@ -207,6 +213,43 @@ spec:
- name: vault-creds
mountPath: "/mnt/secrets-store"
readOnly: true
{{- end }}
{{- if .Values.postgresql.external.pgbouncer.enabled }}
- name: pgbouncer
image: {{ .Values.postgresql.external.pgbouncer.image | quote }}
imagePullPolicy: {{ .Values.registry.pullPolicy }}
volumeMounts:
- name: vault-creds
mountPath: "/mnt/secrets-store"
readOnly: true
lifecycle:
preStop:
exec:
command:
- /bin/sh
- -c
- killall -INT pgbouncer && sleep 120
env:
- name: DB_HOST
value: {{ .Values.postgresql.external.reportHost }}
- name: DB_PORT
value: {{ .Values.postgresql.external.reportPort | quote }}
- name: DB_NAME
value: {{ .Values.postgresql.external.reportDbName }}
- name: POOL_MODE
value: transaction
- name: SERVER_RESET_QUERY
value: DISCARD ALL
- name: DB_USER
valueFrom:
secretKeyRef:
name: {{ $secret_name }}
key: reportDbUser
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ $secret_name }}
key: reportDbPass
{{- end }}
volumes:
{{- if eq .Values.fs.type "CSI" }}
Expand Down
43 changes: 43 additions & 0 deletions charts/allure-testops/templates/allure/uaa-dep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ spec:
resources:
{{ toYaml . | indent 12 }}
{{- end }}
{{- if .Values.postgresql.external.pgbouncer.enabled }}
command: [ 'sh', '-c',
'until pg_isready -h {{ .Values.postgresql.external.uaaHost }} -p {{ .Values.postgresql.external.uaaPort }};
do echo waiting for database; sleep 2; done;' ]
{{- else }}
command: [ 'sh', '-c',
'until pg_isready -h {{ template "uaaDBHost" . }} -p {{ template "uaaDBPort" . }};
do echo waiting for database; sleep 2; done;' ]
{{- end }}
containers:
- name: {{ template "allure-testops.uaa.fullname" . }}
image: "{{ template "getImageRegistry" . }}{{ .Values.uaa.image }}:{{ .Values.version | default .Chart.AppVersion }}"
Expand Down Expand Up @@ -274,6 +280,43 @@ spec:
- name: vault-creds
mountPath: "/mnt/secrets-store"
readOnly: true
{{- if .Values.postgresql.external.pgbouncer.enabled }}
- name: pgbouncer
image: {{ .Values.postgresql.external.pgbouncer.image | quote }}
imagePullPolicy: {{ .Values.registry.pullPolicy }}
volumeMounts:
- name: vault-creds
mountPath: "/mnt/secrets-store"
readOnly: true
lifecycle:
preStop:
exec:
command:
- /bin/sh
- -c
- killall -INT pgbouncer && sleep 120
env:
- name: DB_HOST
value: {{ .Values.postgresql.external.uaaHost }}
- name: DB_PORT
value: {{ .Values.postgresql.external.uaaPort | quote }}
- name: DB_NAME
value: {{ .Values.postgresql.external.uaaDbName }}
- name: POOL_MODE
value: transaction
- name: SERVER_RESET_QUERY
value: DISCARD ALL
- name: DB_USER
valueFrom:
secretKeyRef:
name: {{ $secret_name }}
key: uaaDbUser
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ $secret_name }}
key: uaaDbPass
{{- end }}
volumes:
- name: vault-creds
csi:
Expand Down
3 changes: 3 additions & 0 deletions charts/allure-testops/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ postgresql:
reportDbName: report
reportUsername: report
reportPassword: secret
pgbouncer:
enabled: false
image: docker.io/edoburu/pgbouncer:1.20.1-p0
# This works for built-in postgres only provided with this chart. For external DB you need to execute these manually when creating the databases
primary:
initdb:
Expand Down

0 comments on commit 64c4570

Please sign in to comment.