Skip to content

Commit

Permalink
Use own configuration for postgres deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
tomijange committed Dec 12, 2023
1 parent 7474460 commit a0a7976
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 15 deletions.
9 changes: 3 additions & 6 deletions Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 12.6.6
digest: sha256:eea00e724f08def137f8205b5a6170559a2ae6d8205be5cf3a713f8d1978c6ba
generated: "2023-07-18T17:26:54.029647604+02:00"
dependencies: []
digest: sha256:643d5437104296e21d906ecb15b2c96ad278f20cfc4af53b12bb6069bd853726
generated: "2023-12-12T11:57:06.465369+01:00"
7 changes: 2 additions & 5 deletions Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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: 1.1.1
version: 1.1.2

# 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 All @@ -26,7 +26,4 @@ version: 1.1.1
appVersion: "1.16.0"


dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 12.6.6
dependencies: []
58 changes: 58 additions & 0 deletions templates/postgres-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ include "hawk.fullname" . }}-postgres"
labels:
{{- include "hawk.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.postgres.replicaCount }}
selector:
matchLabels:
app: "{{ include "hawk.fullname" . }}-postgres"
template:
metadata:
{{- with .Values.postgres.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app: "{{ include "hawk.fullname" . }}-postgres"
spec:
{{- with .Values.postgres.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "hawk.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.postgres.podSecurityContext | nindent 8 }}
containers:
- name: "{{ include "hawk.fullname" . }}-postgres"
securityContext:
{{- toYaml .Values.postgres.securityContext | nindent 12 }}
image: "{{ .Values.postgres.image.repository }}:{{ .Values.postgres.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.postgres.image.pullPolicy }}
env:
- name: POSTGRES_USER
value: {{ .Values.postgres.auth.user }}
- name: POSTGRES_PASSWORD
value: {{ .Values.postgres.auth.password }}
- name: POSTGRES_DB
value: {{ .Values.postgres.auth.database }}
ports:
- name: postgres
containerPort: 5432
protocol: TCP
resources:
{{- toYaml .Values.postgres.resources | nindent 12 }}
{{- with .Values.postgres.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.postgres.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.postgres.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
15 changes: 15 additions & 0 deletions templates/postgres-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: "{{ include "hawk.fullname" . }}-postgres"
labels:
{{- include "hawk.labels" . | nindent 4 }}
spec:
type: {{ .Values.postgres.service.type }}
ports:
- port: {{ .Values.postgres.service.port }}
targetPort: postgres
protocol: TCP
name: http
selector:
app: "{{ include "hawk.fullname" . }}-postgres"
4 changes: 2 additions & 2 deletions templates/service-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ spec:
imagePullPolicy: {{ .Values.service.image.pullPolicy }}
env:
- name: SPRING_DATASOURCE_URL
value: "jdbc:postgresql://{{ .Release.Name }}-postgresql.{{ .Release.Namespace }}.svc/{{ .Values.postgresql.auth.database }}"
value: "jdbc:postgresql://{{ .Release.Name }}-postgresql.{{ .Release.Namespace }}.svc/{{ .Values.postgres.auth.database }}"
- name: SPRING_DATASOURCE_USERNAME
value: {{ .Values.postgresql.auth.username }}
value: {{ .Values.postgres.auth.username }}
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
Expand Down
10 changes: 8 additions & 2 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,19 @@ monitor:

affinity: {}

postgresql:
postgres:

image:
repository: postgres
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""


auth:
database: "mydb"
username: "myuser"
password: "mysecretpassword"
enablePostgresUser: true

podAnnotations: {}

Expand Down

0 comments on commit a0a7976

Please sign in to comment.