Skip to content
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

[-] fix helm chart affinity, toleration, nodeSelector and extraVolumes for daemon container #631

Merged
merged 9 commits into from
Jul 6, 2023
126 changes: 74 additions & 52 deletions helm-chart/templates/deployment.yaml
Expand Up @@ -100,60 +100,82 @@ spec:
- name: BOOTSTRAP_TYPE
value: {{ .Values.bootstrap.type | default "configdb" | quote }}
volumes:
- name: config-volume
configMap:
name: pgwatch2-config
optional: true
- name: config-volume
configMap:
name: pgwatch2-config
optional: true
{{- if .Values.daemon.extraVolumes }}
{{- .Values.daemon.extraVolumes | toYaml | nindent 8 }}
{{- end }}

containers:
- name: {{ .Chart.Name }}-daemon
image: "{{ .Values.daemon.image.repository }}:{{ .Values.daemon.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.daemon.image.pullPolicy }}
env:
- name: PW2_PGHOST
value: {{ .Values.postgresql.host | default (printf "%s-postgresql" (include "pgwatch2.fullname" .)) }}
- name: PW2_PGPORT
value: {{ .Values.postgresql.port | default "5432" | quote }}
- name: PW2_PGDATABASE
value: {{ .Values.postgresql.database | default "pgwatch2" }}
- name: PW2_PGUSER
value: {{ .Values.postgresql.user | default "pgwatch2" }}
- name: PW2_PGPASSWORD
value: {{ .Values.postgresql.password | default "pgwatch2" }}
- name: PW2_PGSSL
value: {{ .Values.postgresql.ssl | default "False" | quote }}
{{ if eq .Values.storage "influx" }}
- name: PW2_IHOST
value: {{ include "pgwatch2.fullname" . }}-influxdb
- name: PW2_IPORT
value: {{ .Values.influxdb.port | default "8086" | quote }}
- name: PW2_IDATABASE
value: {{ .Values.influxdb.database | default "pgwatch2" }}
- name: PW2_IUSER
value: {{ .Values.influxdb.user | default "pgwatch2" }}
- name: PW2_IPASSWORD
value: {{ .Values.influxdb.password | default "pgwatch2" }}
- name: PW2_ISSL
value: {{ .Values.influxdb.ssl | default "False" | quote }}
{{ else if eq .Values.storage "postgres" }}
- name: PW2_DATASTORE
value: {{ .Values.storage | quote }}
- name: PW2_PG_METRIC_STORE_CONN_STR
value: {{ printf "postgresql://%s:%s@%s:%s/%s" (.Values.postgresql.user | default "pgwatch2") (.Values.postgresql.password | default "pgwatch2" ) ( .Values.postgresql.host | default (printf "%s-postgresql" (include "pgwatch2.fullname" .))) (.Values.postgresql.port | default "5432") (.Values.postgres_storage.database | default "pgwatch2_metrics" ) }}
- name: PW2_PG_RETENTION_DAYS
value: {{ .Values.postgres_storage.retention_days | default "14" | quote }}
{{ end }}
- name: PW2_INTERNAL_STATS_PORT
value: {{ .Values.daemon.port | default "8081" | quote }}
- name: PW2_WEBNOANONYMOUS
value: {{ .Values.webui.noanonymous | default "False" | quote }}
- name: PW2_WEBUSER
value: {{ .Values.webui.user | default "pgwatch2" }}
- name: PW2_WEBPASSWORD
value: {{ .Values.webui.password | default "pgwatch2" }}
envFrom:
- configMapRef:
name: {{ include "pgwatch2.fullname" . }}-env
- name: {{ .Chart.Name }}-daemon
image: "{{ .Values.daemon.image.repository }}:{{ .Values.daemon.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.daemon.image.pullPolicy }}
env:
- name: PW2_PGHOST
value: {{ .Values.postgresql.host | default (printf "%s-postgresql" (include "pgwatch2.fullname" .)) }}
- name: PW2_PGPORT
value: {{ .Values.postgresql.port | default "5432" | quote }}
- name: PW2_PGDATABASE
value: {{ .Values.postgresql.database | default "pgwatch2" }}
- name: PW2_PGUSER
value: {{ .Values.postgresql.user | default "pgwatch2" }}
- name: PW2_PGPASSWORD
value: {{ .Values.postgresql.password | default "pgwatch2" }}
- name: PW2_PGSSL
value: {{ .Values.postgresql.ssl | default "False" | quote }}
{{ if eq .Values.storage "influx" }}
- name: PW2_IHOST
value: {{ include "pgwatch2.fullname" . }}-influxdb
- name: PW2_IPORT
value: {{ .Values.influxdb.port | default "8086" | quote }}
- name: PW2_IDATABASE
value: {{ .Values.influxdb.database | default "pgwatch2" }}
- name: PW2_IUSER
value: {{ .Values.influxdb.user | default "pgwatch2" }}
- name: PW2_IPASSWORD
value: {{ .Values.influxdb.password | default "pgwatch2" }}
- name: PW2_ISSL
value: {{ .Values.influxdb.ssl | default "False" | quote }}
{{ else if eq .Values.storage "postgres" }}
- name: PW2_DATASTORE
value: {{ .Values.storage | quote }}
- name: PW2_PG_METRIC_STORE_CONN_STR
value: {{ printf "postgresql://%s:%s@%s:%s/%s" (.Values.postgresql.user | default "pgwatch2") (.Values.postgresql.password | default "pgwatch2" ) ( .Values.postgresql.host | default (printf "%s-postgresql" (include "pgwatch2.fullname" .))) (.Values.postgresql.port | default "5432") (.Values.postgres_storage.database | default "pgwatch2_metrics" ) }}
- name: PW2_PG_RETENTION_DAYS
value: {{ .Values.postgres_storage.retention_days | default "14" | quote }}
{{ end }}
- name: PW2_INTERNAL_STATS_PORT
value: {{ .Values.daemon.port | default "8081" | quote }}
- name: PW2_WEBNOANONYMOUS
value: {{ .Values.webui.noanonymous | default "False" | quote }}
- name: PW2_WEBUSER
value: {{ .Values.webui.user | default "pgwatch2" }}
- name: PW2_WEBPASSWORD
value: {{ .Values.webui.password | default "pgwatch2" }}
envFrom:
- configMapRef:
name: {{ include "pgwatch2.fullname" . }}-env
{{- if .Values.daemon.extraVolumeMounts }}
{{- .Values.daemon.extraVolumeMounts | toYaml | nindent 12 }}
{{- end }}
{{- with .Values.daemon.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{ end }}
---
{{ if .Values.webui.enabled }}
Expand Down
74 changes: 38 additions & 36 deletions helm-chart/values.yaml
Expand Up @@ -9,23 +9,23 @@ metrics_preset:
metrics: '{"kpi": 120, "wal": 60, "locks": 60, "db_size": 300, "archiver": 60, "backends": 60, "bgwriter": 60, "cpu_load": 60, "db_stats": 60, "settings": 7200, "wal_size": 300, "locks_mode": 60, "index_stats": 900, "replication": 120, "sproc_stats": 180, "table_stats": 300, "wal_receiver": 120, "change_events": 300, "table_io_stats": 600, "sequence_health": 3600, "replication_slots": 120}'

databases:
- host: pgwatch2-postgresql
grafana_preset_metrics: remotedba
port: 5432
user: pgwatch2
password: 'pgwatch2'
dbs:
- postgres
- foo
- bar
- host: pgwatch2-postgresql-hl
grafana_preset_metrics: remotedba
port: 5432
user: pgwatch2
password: 'pgwatch2'
dbs:
- postgres
- pgwatch2
- host: pgwatch2-postgresql
grafana_preset_metrics: remotedba
port: 5432
user: pgwatch2
password: "pgwatch2"
dbs:
- postgres
- foo
- bar
- host: pgwatch2-postgresql-hl
grafana_preset_metrics: remotedba
port: 5432
user: pgwatch2
password: "pgwatch2"
dbs:
- postgres
- pgwatch2

daemon:
enabled: true
Expand All @@ -37,6 +37,9 @@ daemon:
PW2_PG_RETENTION_DAYS: "14"
PW2_MIN_DB_SIZE_MB: "0"

extraVolumes: {}
extraVolumeMounts: {}

bootstrap:
image:
repository: cybertec/pgwatch2-db-bootstrapper
Expand Down Expand Up @@ -72,7 +75,8 @@ webui:
# See https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/#specifying-the-class-of-an-ingress
# ingressClassName: nginx
# Values can be templated
annotations: {}
annotations:
{}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
labels: {}
Expand All @@ -98,13 +102,11 @@ webui:
# port:
# name: use-annotation


tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local


grafana:
sidecar:
dashboards:
Expand Down Expand Up @@ -171,27 +173,27 @@ grafana:
datasources.yaml:
apiVersion: 1
datasources:
- name: InfluxDB_v1
type: influxdb
access: proxy
url: http://pgwatch2-influxdb:8086
isDefault: true
database: pgwatch2
user: pgwatch2
jsonData:
httpMode: GET
secureJsonData:
password: pgwatch2
- name: InfluxDB_v1
type: influxdb
access: proxy
url: http://pgwatch2-influxdb:8086
isDefault: true
database: pgwatch2
user: pgwatch2
jsonData:
httpMode: GET
secureJsonData:
password: pgwatch2
## Postgresql
# - name: Postgres
# type: postgres
# url: pgwatch2-postgresql:5432
# isDefault: true
# database: *metricsdatabase
# user: *postgresuser
# secureJsonData:
# password: *postgrespassword
# jsonData:
# database: *metricsdatabase
# sslmode: 'disable' # disable/require/verify-ca/verify-full
# maxOpenConns: 0 # Grafana v5.4+
# maxIdleConns: 2 # Grafana v5.4+
Expand All @@ -207,7 +209,7 @@ metallb:
enabled: true
configInline:
address-pools:
- name: default
protocol: layer2
addresses:
- 192.168.49.10-192.168.49.250
- name: default
protocol: layer2
addresses:
- 192.168.49.10-192.168.49.250