diff --git a/postgresql/templates/secret-admin.yaml b/postgresql/templates/secret-admin.yaml new file mode 100644 index 0000000000..93903e3539 --- /dev/null +++ b/postgresql/templates/secret-admin.yaml @@ -0,0 +1,26 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} +{{- if .Values.manifests.secret_admin }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.secrets.postgresql.admin }} +type: Opaque +data: + POSTGRES_USER: {{ .Values.endpoints.postgresql.auth.admin.username | b64enc }} + POSTGRES_PASSWORD: {{ .Values.endpoints.postgresql.auth.admin.password | b64enc }} +{{- end }} diff --git a/postgresql/templates/statefulset.yaml b/postgresql/templates/statefulset.yaml index 13c686ab3f..1b3a65ad31 100644 --- a/postgresql/templates/statefulset.yaml +++ b/postgresql/templates/statefulset.yaml @@ -45,6 +45,17 @@ spec: imagePullPolicy: {{ .Values.images.pull_policy }} ports: - containerPort: {{ tuple "postgresql" "internal" "postgresql" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} + env: + - name: 'POSTGRES_PASSWORD' + valueFrom: + secretKeyRef: + name: {{ .Values.secrets.postgresql.admin }} + key: 'POSTGRES_PASSWORD' + - name: 'POSTGRES_USER' + valueFrom: + secretKeyRef: + name: {{ .Values.secrets.postgresql.admin }} + key: 'POSTGRES_USER' livenessProbe: exec: command: diff --git a/postgresql/values.yaml b/postgresql/values.yaml index 6e45c89064..884df07e51 100644 --- a/postgresql/values.yaml +++ b/postgresql/values.yaml @@ -60,9 +60,17 @@ dependencies: postgresql: jobs: null +secrets: + postgresql: + admin: postgresql-admin + endpoints: cluster_domain_suffix: cluster.local postgresql: + auth: + admin: + username: postgres + password: sergtsop hosts: default: postgresql host_fqdn_override: @@ -72,3 +80,6 @@ endpoints: port: postgresql: default: 5432 + +manifests: + secret_admin: true