-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(helm): add support for pgbouncer (#818) #818
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: v1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I wonder whether it would be possible to amend the setup to automatically delete / refresh This comment is a sort of a "bonus", the things work nicely 👍 and I'm not sure whether admins would attempt to play with enabling/disabling PgBouncer dynamically in reality... Well we could always simply explain this in the documentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have updated the PR to also roll the deployments of pgbouncer/r-server/r-w-controller when the database config (configmap or secrets) change. This can be used as a blueprint to do the same for the other config/secret that might change over time. |
||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "reana.prefix" . }}-database-config | ||
namespace: {{ .Release.Namespace }} | ||
data: | ||
REANA_DB_NAME: {{ .Values.db_env_config.REANA_DB_NAME | quote }} | ||
{{- if .Values.pgbouncer.enabled }} | ||
REANA_DB_HOST: {{ include "reana.prefix" . }}-pgbouncer | ||
REANA_DB_PORT: "6432" | ||
{{- else if .Values.components.reana_db.enabled }} | ||
REANA_DB_HOST: {{ include "reana.prefix" . }}-db | ||
REANA_DB_PORT: "5432" | ||
{{- else }} | ||
REANA_DB_HOST: {{ .Values.db_env_config.REANA_DB_HOST | quote }} | ||
REANA_DB_PORT: {{ .Values.db_env_config.REANA_DB_PORT | quote }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ include "reana.prefix" . }}-db-secrets | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
"helm.sh/resource-policy": keep | ||
type: Opaque | ||
data: | ||
user: {{ .Values.secrets.database.user | default "reana" | b64enc }} | ||
password: {{ .Values.secrets.database.password | default "reana" | b64enc }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{- if .Values.pgbouncer.enabled }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "reana.prefix" . }}-pgbouncer-config | ||
namespace: {{ .Release.Namespace }} | ||
data: | ||
PGBOUNCER_POOL_MODE: {{ .Values.pgbouncer.pool_mode | quote }} | ||
PGBOUNCER_MAX_CLIENT_CONN: {{ .Values.pgbouncer.max_client_conn | quote }} | ||
PGBOUNCER_MAX_DB_CONNECTIONS: {{ .Values.pgbouncer.max_db_connections | quote }} | ||
PGBOUNCER_DEFAULT_POOL_SIZE: {{ .Values.pgbouncer.max_db_connections | quote }} | ||
{{- if .Values.components.reana_db.enabled }} | ||
PGBOUNCER_DATABASE: reana | ||
POSTGRESQL_HOST: {{ include "reana.prefix" . }}-db | ||
POSTGRESQL_PORT: "5432" | ||
{{- else }} | ||
PGBOUNCER_DATABASE: {{ .Values.db_env_config.REANA_DB_NAME | quote }} | ||
POSTGRESQL_HOST: {{ .Values.db_env_config.REANA_DB_HOST | quote }} | ||
POSTGRESQL_PORT: {{ .Values.db_env_config.REANA_DB_PORT | quote }} | ||
{{- end }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{- if .Values.pgbouncer.enabled }} | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ include "reana.prefix" . }}-pgbouncer-secrets | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
"helm.sh/resource-policy": keep | ||
type: Opaque | ||
data: | ||
userlist: {{ printf "%s %s" (.Values.secrets.database.user | default "reana" | quote) (.Values.secrets.database.password | default "reana" | quote) | b64enc}} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{{- if .Values.pgbouncer.enabled }} | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ include "reana.prefix" . }}-pgbouncer | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: {{ include "reana.prefix" . }}-pgbouncer | ||
ports: | ||
- port: 6432 | ||
targetPort: 6432 | ||
protocol: TCP | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "reana.prefix" . }}-pgbouncer | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
replicas: {{ if .Values.maintenance.enabled -}} 0 {{- else -}} 1 {{- end }} | ||
selector: | ||
matchLabels: | ||
app: {{ include "reana.prefix" . }}-pgbouncer | ||
template: | ||
metadata: | ||
labels: | ||
app: {{ include "reana.prefix" . }}-pgbouncer | ||
annotations: | ||
checksum/pgbouncer-config: {{ include (print $.Template.BasePath "/pgbouncer-config.yaml") . | sha256sum }} | ||
checksum/pgbouncer-secrets: {{ include (print $.Template.BasePath "/pgbouncer-secrets.yaml") . | sha256sum }} | ||
checksum/database-secrets: {{ include (print $.Template.BasePath "/database-secrets.yaml") . | sha256sum }} | ||
spec: | ||
containers: | ||
- name: pgbouncer | ||
image: {{ .Values.pgbouncer.image | quote }} | ||
ports: | ||
- containerPort: 6432 | ||
envFrom: | ||
- configMapRef: | ||
name: {{ include "reana.prefix" . }}-pgbouncer-config | ||
env: | ||
- name: POSTGRESQL_USERNAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ include "reana.prefix" . }}-db-secrets | ||
key: user | ||
- name: POSTGRESQL_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ include "reana.prefix" . }}-db-secrets | ||
key: password | ||
- name: PGBOUNCER_USERLIST | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ include "reana.prefix" . }}-pgbouncer-secrets | ||
key: userlist | ||
{{- range $key, $value := .Values.pgbouncer.environment }} | ||
- name: {{ $key }} | ||
value: {{ $value | quote }} | ||
{{- end }} | ||
{{- if .Values.node_label_infrastructuredb }} | ||
{{- $full_label := split "=" .Values.node_label_infrastructuredb }} | ||
nodeSelector: | ||
{{ $full_label._0 }}: {{ $full_label._1 }} | ||
{{- else if .Values.node_label_infrastructure }} | ||
{{- $full_label := split "=" .Values.node_label_infrastructure }} | ||
nodeSelector: | ||
{{ $full_label._0 }}: {{ $full_label._1 }} | ||
{{- end }} | ||
{{- end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
pgbouncer
is enabled, shall we act onreana-job-controller
'sREANA_DB_CLOSE_POOL_CONNECTIONS
configuration value?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's actually the opposite, if pgbouncer is not enabled then the two options are:
REANA_DB_CLOSE_POOL_CONNECTIONS
appropriatelyI have kept the default value of
REANA_DB_CLOSE_POOL_CONNECTIONS
as to have the best performance possible, but it is customisable so that we can revert back the change in case of troubles with PgBouncer.What do you think we should do regarding this? Shall we add this to the documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can later improve the scalability-related documentation regarding PgBouncer.