diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 36f9c35..8c5d047 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -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 diff --git a/helm/config/bookkeeper.yml b/helm/config/bookkeeper.yml index 4256ae4..cb8518d 100644 --- a/helm/config/bookkeeper.yml +++ b/helm/config/bookkeeper.yml @@ -30,8 +30,8 @@ database: # url: jdbc:postgresql://postgres.bookkeeper.svc.cluster.local:5432/bookkeeper # Connect with database username and password - user: - password: + user: {{ .Values.postgres.user }} + password: # This is in a Secret, so can't get it from .Values. # JDBC driver properties properties: diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index 9a8092f..684760d 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -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 }} diff --git a/helm/templates/postgres.yaml b/helm/templates/postgres.yaml new file mode 100644 index 0000000..7de673c --- /dev/null +++ b/helm/templates/postgres.yaml @@ -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