diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml index 60f02530a..f29f3751a 100644 --- a/chart/templates/deployment.yaml +++ b/chart/templates/deployment.yaml @@ -22,7 +22,9 @@ spec: labels: {{- include "canary-checker.labels" . | nindent 10 }} spec: + {{- if not (eq .Values.db.embedded.storageClass "") }} storageClassName: {{ .Values.db.embedded.storageClass }} + {{- end }} accessModes: ["ReadWriteOnce"] resources: requests: @@ -96,7 +98,7 @@ spec: {{- if .Values.upstream.enabled }} envFrom: - secretRef: - name: {{ include "canary-checker.name" . }} + name: {{ .Values.upstream.secretKeyRef.name }} {{- end }} volumeMounts: {{- if eq .Values.dockerSocket true }} @@ -140,7 +142,7 @@ spec: {{- end }} {{- if .Values.upstream.enabled }} - --agent-name={{ .Values.upstream.agentName }} - - --upstream-host={{ .Values.upstream.host }} + - --upstream-host=$UPSTREAM_HOST - --upstream-user=$UPSTREAM_USER - --upstream-password=$UPSTREAM_PASSWORD {{- end }} diff --git a/chart/templates/postgres-statefulset.yaml b/chart/templates/postgres-statefulset.yaml index e5213bf4a..7b70e00e5 100644 --- a/chart/templates/postgres-statefulset.yaml +++ b/chart/templates/postgres-statefulset.yaml @@ -32,7 +32,9 @@ spec: name: postgresql spec: accessModes: ["ReadWriteOnce"] + {{- if not (eq .Values.db.external.storageClass "") }} storageClassName: {{ .Values.db.external.storageClass }} + {{- end }} resources: requests: storage: {{ .Values.db.external.storage }} diff --git a/chart/templates/secret.yaml b/chart/templates/secret.yaml deleted file mode 100644 index eaa352544..000000000 --- a/chart/templates/secret.yaml +++ /dev/null @@ -1,9 +0,0 @@ -{{- if .Values.upstream.enabled }} -apiVersion: v1 -kind: Secret -metadata: - name: {{ include "canary-checker.name" . }} -data: - UPSTREAM_USERNAME: {{ .Values.upstream.username | b64enc }} - UPSTREAM_PASSWORD: {{ .Values.upstream.password | b64enc }} -{{- end }} diff --git a/chart/values.yaml b/chart/values.yaml index 54b29ed36..32198c9a4 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -36,7 +36,7 @@ db: # If the database is embedded, setting this to true will persist the contents of the database # through a persistent volume persist: false - storageClass: + storageClass: "" storage: 20Gi external: # Setting enabled to true will use a external postgres DB, disabling the embedded DB @@ -54,7 +54,7 @@ db: # this is the key it will look for in the secret(if secretRefKey is # mentioned). The name of the key is mandatory to set. key: DB_URL - storageClass: + storageClass: "" storage: 20Gi nameOverride: "" @@ -72,10 +72,10 @@ data: upstream: enabled: false - host: "" - agentName: "" - username: "" - password: "" + agentName: default-agent + # Must contain: UPSTREAM_USER, UPSTREAM_PASS & UPSTREAM_HOST + secretKeyRef: + name: canary-checker-upstream ingress: enabled: false diff --git a/pkg/db/init.go b/pkg/db/init.go index 5aa8d568d..0ea2e128e 100644 --- a/pkg/db/init.go +++ b/pkg/db/init.go @@ -56,11 +56,7 @@ func IsConnected() bool { func embeddedDB() error { embeddedPath := strings.TrimSuffix(strings.TrimPrefix(ConnectionString, "embedded://"), "/") - err := os.Chmod(embeddedPath, 0750) - if err != nil { - logger.Errorf("Error changing permission of dataPath: %v, Error: %v", embeddedPath, err) - return err - } + _ = os.Chmod(embeddedPath, 0750) logger.Infof("Starting embedded postgres server at %s", embeddedPath) @@ -73,8 +69,7 @@ func embeddedDB() error { Username("postgres").Password("postgres"). Database("canary")) ConnectionString = "postgres://postgres:postgres@localhost:6432/canary?sslmode=disable" - err = PostgresServer.Start() - if err != nil { + if err := PostgresServer.Start(); err != nil { return fmt.Errorf("error starting embedded postgres: %v", err) } return nil