Support configurable admin credentials in Postgres

- Use endpoints auth section
- Store user and password in secrets
- Set them in the statefulset Pod environment

Change-Id: I9e503243f6ca157c4257475e902aa8138d2b089e
This commit is contained in:
Scott Hussey 2018-01-23 14:25:26 -06:00
parent b66b6a0697
commit 8960dc1b3a
3 changed files with 48 additions and 0 deletions

View File

@ -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 }}

View File

@ -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:

View File

@ -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