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

feat: #issue 857 adds condition for svc name if external db is enabled #155

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion charts/clair/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ maintainers:
name: clair
sources:
- https://github.com/coreos/clair
version: 0.1.9
version: 0.1.10
14 changes: 8 additions & 6 deletions charts/clair/templates/_config.yaml.tpl
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{{- $postgresHost := (include "postgres.host" $) }}

introspection_addr: {{ .Values.config.introspection_addr }}
http_listen_addr: {{ .Values.config.http_listen_addr }}
log_level: {{ .Values.config.log_level }}
indexer:
{{- if .Values.config.postgresPassword }}
connstring: "host={{ .Values.config.postgresHost }} port={{ .Values.config.postgresPort }} dbname={{ .Values.config.postgresdbname }} user={{ .Values.config.postgresUser }} password={{ .Values.config.postgresPassword }} sslmode=disable"
connstring: "host={{ $postgresHost }} port={{ .Values.config.postgresPort }} dbname={{ .Values.config.postgresdbname }} user={{ .Values.config.postgresUser }} password={{ .Values.config.postgresPassword }} sslmode=disable"
{{- else }}
connstring: "host={{ .Values.config.postgresHost }} port={{ .Values.config.postgresPort }} dbname={{ .Values.config.postgresdbname }} user={{ .Values.config.postgresUser }} sslmode=disable"
connstring: "host={{ $postgresHost }} port={{ .Values.config.postgresPort }} dbname={{ .Values.config.postgresdbname }} user={{ .Values.config.postgresUser }} sslmode=disable"
{{- end }}
scanlock_retry: {{ .Values.config.indexer.scanlock_retry }}
layer_scan_concurrency: {{ .Values.config.indexer.layer_scan_concurrency }}
Expand All @@ -16,9 +18,9 @@ indexer:
matcher:
indexer_addr: "{{ .Values.config.matcher.indexer_addr }}"
{{- if .Values.config.postgresPassword }}
connstring: "host={{ .Values.config.postgresHost }} port={{ .Values.config.postgresPort }} dbname={{ .Values.config.postgresdbname }} user={{ .Values.config.postgresUser }} password={{ .Values.config.postgresPassword }} sslmode=disable"
connstring: "host={{ $postgresHost }} port={{ .Values.config.postgresPort }} dbname={{ .Values.config.postgresdbname }} user={{ .Values.config.postgresUser }} password={{ .Values.config.postgresPassword }} sslmode=disable"
{{- else }}
connstring: "host={{ .Values.config.postgresHost }} port={{ .Values.config.postgresPort }} dbname={{ .Values.config.postgresdbname }} user={{ .Values.config.postgresUser }} sslmode=disable"
connstring: "host={{ $postgresHost }} port={{ .Values.config.postgresPort }} dbname={{ .Values.config.postgresdbname }} user={{ .Values.config.postgresUser }} sslmode=disable"
{{- end }}
max_conn_pool: {{ .Values.config.matcher.max_conn_pool }}
run: ""
Expand All @@ -32,9 +34,9 @@ matcher:
{{- end }}
notifier:
{{- if .Values.config.postgresPassword }}
connstring: "host={{ .Values.config.postgresHost }} port={{ .Values.config.postgresPort }} dbname={{ .Values.config.postgresdbname }} user={{ .Values.config.postgresUser }} password={{ .Values.config.postgresPassword }} sslmode=disable"
connstring: "host={{ $postgresHost }} port={{ .Values.config.postgresPort }} dbname={{ .Values.config.postgresdbname }} user={{ .Values.config.postgresUser }} password={{ .Values.config.postgresPassword }} sslmode=disable"
{{- else }}
connstring: "host={{ .Values.config.postgresHost }} port={{ .Values.config.postgresPort }} dbname={{ .Values.config.postgresdbname }} user={{ .Values.config.postgresUser }} sslmode=disable"
connstring: "host={{ $postgresHost }} port={{ .Values.config.postgresPort }} dbname={{ .Values.config.postgresdbname }} user={{ .Values.config.postgresUser }} sslmode=disable"
{{- end }}
delivery_interval: {{ .Values.config.notifier.delivery_interval }}
poll_interval: {{ .Values.config.notifier.poll_interval }}
Expand Down
10 changes: 10 additions & 0 deletions charts/clair/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{{/* Returns Postgres db service name */}}

{{- define "postgres.host" }}
{{- if $.Values.global.externalDatabase }}
{{- print "clair-postgresql.devtroncd" }}
{{- else }}
{{- print "postgresql-postgresql.devtroncd" }}
{{- end }}
{{- end }}

{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
Expand Down
3 changes: 2 additions & 1 deletion charts/clair/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- $postgresHost := (include "postgres.host" $) }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -41,7 +42,7 @@ spec:
- name: pg-ready-wait
image: postgres:11.3
command: [ "sh", "-c",
"until pg_isready -h {{ .Values.config.postgresHost }} -p {{ .Values.config.postgresPort }};
"until pg_isready -h {{ $postgresHost }} -p {{ .Values.config.postgresPort }};
do echo waiting for database; sleep 1; done;"]
containers:
- name: {{ .Chart.Name }}
Expand Down
2 changes: 1 addition & 1 deletion charts/clair/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
config:
postgresHost: postgresql-postgresql.devtroncd
# postgresHost: postgresql-postgresql.devtroncd
postgresPort: 5432
postgresdbname: clairv4
postgresUser: postgres
Expand Down
4 changes: 2 additions & 2 deletions charts/security/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ maintaintainers:
email: [email protected]
sources:
- https://github.com/devtron-labs/charts
version: 0.1.4
version: 0.1.5
appVersion: "0.1.1"
dependencies:
- name: clair
version: "0.x.x"
version: "0.1.10"
repository: https://helm.devtron.ai
condition: clair.enabled
19 changes: 19 additions & 0 deletions charts/security/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{/* Returns Postgres db service name */}}

{{- define "postgres.host" }}
{{- if $.Values.global.externalDatabase }}
{{- print "clair-postgresql.devtroncd" }}
{{- else }}
{{- print "postgresql-postgresql.devtroncd" }}
{{- end }}
{{- end }}

{{/* Returns Postgres db name */}}

{{- define "postgres.db" }}
{{- if $.Values.global.externalDatabase }}
{{- print "clairv4" }}
{{- else }}
{{- print "orchestrator" }}
{{- end }}
{{- end }}
8 changes: 6 additions & 2 deletions charts/security/templates/image-scanner.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{- $postgresHost := (include "postgres.host" $) }}
{{- $postgresDB := (include "postgres.db" $) }}
{{- with .Values.imageScanner }}
apiVersion: v1
kind: Secret
Expand All @@ -8,7 +10,7 @@ metadata:
release: {{ $.Release.Name }}
integration: security
{{- if .labels }}
{{ toYaml .labels | indent 4 }}
{{ toYaml .labels | indent 4 }}
{{- end}}
type: Opaque
{{- if .secrets }}
Expand All @@ -30,6 +32,8 @@ metadata:
{{ toYaml .labels | indent 4 }}
{{- end}}
data:
PG_ADDR: {{ $postgresHost }}
PG_DATABASE: {{ $postgresDB }}
{{- if .configs}}
{{ toYaml .configs | indent 2 }}
---
Expand Down Expand Up @@ -133,4 +137,4 @@ spec:
{{ toYaml .tolerations | indent 8 }}
{{- end }}
revisionHistoryLimit: 3
{{- end }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/security/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ imageScanner:
CLAIR_ADDR: clair.devtroncd:6060
CLIENT_ID: client-2
NATS_SERVER_HOST: nats://devtron-nats.devtroncd:4222
PG_ADDR: postgresql-postgresql.devtroncd
PG_DATABASE: orchestrator
# PG_ADDR: postgresql-postgresql.devtroncd
# PG_DATABASE: orchestrator
PG_LOG_QUERY: "false"
PG_PORT: "5432"
PG_USER: postgres
Expand Down