Skip to content

Commit

Permalink
Updated configmap to use tpl to substitute values in config files.
Browse files Browse the repository at this point in the history
The bookkeeper.yml file can now get values from values.yaml which
are substituted using the template syntax.  Still need to figure out how
to pass in the secret that way.

Also committed the postgres.yaml config that I forgot last time.

This continues work on issue #66.
  • Loading branch information
mbjones committed Feb 18, 2022
1 parent 35145ea commit 4e4b3ef
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 4 deletions.
2 changes: 1 addition & 1 deletion helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.2
version: 0.0.3

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
4 changes: 2 additions & 2 deletions helm/config/bookkeeper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ database:
# url: jdbc:postgresql://postgres.bookkeeper.svc.cluster.local:5432/bookkeeper

# Connect with database username and password
user: <user goes here>
password: <password goes here>
user: {{ .Values.postgres.user }}
password: <password goes here> # This is in a Secret, so can't get it from .Values.

# JDBC driver properties
properties:
Expand Down
2 changes: 1 addition & 1 deletion helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ metadata:
labels:
{{- include "bookkeeper.labels" . | nindent 4 }}
data:
{{ (.Files.Glob "config/*").AsConfig | indent 4 }}
{{ (tpl (.Files.Glob "config/*").AsConfig . ) | indent 4 }}
66 changes: 66 additions & 0 deletions helm/templates/postgres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
labels:
{{- include "bookkeeper.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app: postgres
replicas: 1
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: docker.io/postgres:11-alpine
command: [ "su", "-", "postgres", "-c", "postgres -D /opt/local/bookkeeper/postgresql/data" ]
ports:
- name: postgres
containerPort: 5432
imagePullPolicy: IfNotPresent
volumeMounts:
- name: bookkeeper-volume
mountPath: "/opt/local"
readOnly: false
env:
- name: POSTGRES_HOST
valueFrom:
configMapKeyRef:
name: {{ .Release.Name }}-configmap
key: POSTGRES_HOST
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-credentials
key: password
- name: POSTGRES_USER
valueFrom:
configMapKeyRef:
name: {{ .Release.Name }}-configmap
key: POSTGRES_USER
restartPolicy: Always
volumes:
- name: bookkeeper-volume
persistentVolumeClaim:
claimName: bookkeeper-pvc

---

apiVersion: v1
kind: Service
metadata:
name: postgres
labels:
{{- include "bookkeeper.labels" . | nindent 4 }}
spec:
selector:
app: postgres
ports:
- name: postgres
port: 5432
protocol: TCP
targetPort: postgres

0 comments on commit 4e4b3ef

Please sign in to comment.