Skip to content

Commit 99e0c30

Browse files
committed
feat: chart fixes
1 parent 859c95b commit 99e0c30

3 files changed

Lines changed: 50 additions & 38 deletions

File tree

Dockerfile

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ ARG BUILD_DATE=unknown
1212

1313
# Copy source code
1414
WORKDIR /src/postgres
15-
COPY postgres/go.mod postgres/go.sum ./
16-
COPY clicky/go.mod /src/clicky/go.mod
15+
COPY go.mod go.sum ./
1716
RUN go mod download
1817

19-
COPY postgres/ /src/postgres
20-
COPY clicky /src/clicky
18+
COPY . .
2119
# Build pgconfig binary with cache mounts and version info
2220
RUN --mount=type=cache,target=/root/.cache/go-build \
2321
--mount=type=cache,target=/go/pkg/mod \
@@ -134,7 +132,7 @@ RUN set -eux; \
134132
# Make volumes for data and init scripts
135133
VOLUME /var/lib/postgresql/data
136134

137-
COPY postgres/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
135+
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
138136
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
139137

140138

@@ -156,6 +154,3 @@ USER postgres
156154

157155
# Set entrypoint
158156
ENTRYPOINT ["docker-entrypoint.sh"]
159-
160-
# Default command - run PostgreSQL
161-
# CMD ["postgres"]

chart/templates/statefulset.yaml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,38 @@ spec:
5959
{{- toYaml .Values.securityContext | nindent 12 }}
6060
image: {{ include "postgres.image" . }}
6161
imagePullPolicy: {{ .Values.image.pullPolicy }}
62+
resources:
63+
{{- toYaml .Values.resources | nindent 12 }}
6264
command:
6365
- docker-entrypoint.sh
6466
{{- range $k, $v := .Values.conf }}
6567
- '--{{ $k }}={{ $v }}'
6668
{{- end }}
6769
env:
70+
- name: UPGRADE_ONLY
71+
value: "true"
72+
- name: POSTGRES_CLI_ARGS
73+
value: {{ .Values.postgresCliArgs | quote }}
6874
- name: PGDATA
6975
value: /var/lib/postgresql/data
7076
- name: PG_VERSION
7177
value: {{ .Values.version | quote }}
72-
- name: UPGRADE_ONLY
73-
value: "true"
7478
- name: POSTGRES_DB
7579
value: {{ .Values.database.name | quote }}
76-
- name: POSTGRES_PASSWORD
77-
valueFrom:
78-
secretKeyRef:
79-
name: {{ $secretName }}
80-
key: {{ .Values.passwordRef.key }}
80+
- name: POSTGRES_USER
81+
value: {{ .Values.database.username | quote }}
82+
- name: POSTGRES_PASSWORD_FILE
83+
value: /etc/postgresql/password/{{ .Values.passwordRef.key }}
84+
{{- range .Values.env }}
85+
- name: {{ .name }}
86+
value: {{ .value | quote }}
87+
{{- end }}
8188
volumeMounts:
8289
- name: data
8390
mountPath: /var/lib/postgresql/data
91+
- name: password
92+
mountPath: /etc/postgresql/password
93+
readOnly: true
8494
{{- end }}
8595
containers:
8696
- name: postgresql
@@ -98,6 +108,8 @@ spec:
98108
containerPort: 5432
99109
protocol: TCP
100110
env:
111+
- name: POSTGRES_CLI_ARGS
112+
value: {{ .Values.postgresCliArgs | quote }}
101113
- name: PGDATA
102114
value: /var/lib/postgresql/data
103115
- name: PG_VERSION
@@ -106,11 +118,8 @@ spec:
106118
value: {{ .Values.database.name | quote }}
107119
- name: POSTGRES_USER
108120
value: {{ .Values.database.username | quote }}
109-
- name: POSTGRES_PASSWORD
110-
valueFrom:
111-
secretKeyRef:
112-
name: {{ $secretName }}
113-
key: {{ .Values.passwordRef.key }}
121+
- name: POSTGRES_PASSWORD_FILE
122+
value: /etc/postgresql/password/{{ .Values.passwordRef.key }}
114123
{{- range .Values.env }}
115124
- name: {{ .name }}
116125
value: {{ .value | quote }}
@@ -153,7 +162,9 @@ spec:
153162
volumeMounts:
154163
- name: data
155164
mountPath: /var/lib/postgresql/data
156-
165+
- name: password
166+
mountPath: /etc/postgresql/password
167+
readOnly: true
157168
- name: dshm
158169
mountPath: /dev/shm
159170
{{- if or .Values.conf .Values.custom_conf }}
@@ -165,10 +176,14 @@ spec:
165176
- {{- toYaml . | nindent 14 }}
166177
{{- end }}
167178
volumes:
179+
- name: password
180+
secret:
181+
secretName: {{ $secretName }}
182+
defaultMode: 0400
168183
- name: dshm
169184
emptyDir:
170185
medium: Memory
171-
sizeLimit: 1Gi
186+
sizeLimit: {{.Values.dshmSize | default "64Mi" }}
172187
{{- if or .Values.conf .Values.custom_conf }}
173188
- name: config
174189
configMap:

chart/values.yaml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
# Default values for postgres chart
22

3+
# Postgres version to run, flanksource/postgres images include multiple versions allowing you to select at runtime
4+
version: "17"
5+
# Automatic upgrade configuration
6+
autoUpgrade:
7+
enabled: true
8+
9+
## Change ownership and permissions of mounted volumes on startup
10+
resetVolumePermissions: true
11+
12+
dshmSize: 256Mi
13+
14+
# custom arguments to pass to postgres-cli startup
15+
postgresCliArgs: "--pg-tune --auto-upgrade --auto-reset-password --auto-init"
16+
317
# PostgreSQL container image
418
image:
519
registry: ghcr.io
620
repository: flanksource/postgres
721
tag: "17"
822
pullPolicy: IfNotPresent
923

10-
# Postgres version to run, flanksource/postgres images include multiple versions allowing you to select at runtime
11-
version: "17"
12-
# Automatic upgrade configuration
13-
autoUpgrade:
14-
enabled: true
15-
1624
# Database configuration
1725
database:
1826
name: postgres
@@ -35,7 +43,7 @@ conf:
3543
log_directory: "/var/log/postgresql"
3644
log_file_mode: 0644
3745
log_filename: "postgresql-%d.log"
38-
log_line_prefix: "%m [%p] %q[user=%u,db=%d,app=%a] "
46+
log_line_prefix: "%m [%p] %q[user=%u,db=%d,app=%a]"
3947
log_lock_waits: on
4048
log_min_duration_statement: "1s"
4149
# log_rotation_age: "1d"
@@ -49,24 +57,21 @@ conf:
4957
timezone: "UTC"
5058
password_encryption: scram-sha-256
5159

52-
# Custom postgresql.conf override (takes precedence over conf)
53-
custom_conf: ""
54-
5560
# Resource configuration
5661
resources:
5762
limits:
5863
cpu: 2000m
5964
memory: 4Gi
6065
requests:
61-
cpu: 500m
62-
memory: 1Gi
66+
cpu: 20m
67+
memory: 128Mi
6368

6469
# Persistence configuration
6570
persistence:
6671
enabled: true
6772
# Name of existing PVC to use (mutually exclusive with volumeName)
6873
existingClaim: ""
69-
# Name of existing PV to bind to (creates new PVC, mutually exclusive with existingClaim)
74+
# Name of existing PV to bind to (mutually exclusive with existingClaim)
7075
volumeName: ""
7176
storageClass: ""
7277
accessMode: ReadWriteOnce
@@ -144,9 +149,6 @@ livenessProbe:
144149
failureThreshold: 3
145150
successThreshold: 1
146151

147-
## Change ownership and permissions of mounted volumes on startup
148-
resetVolumePermissions: true
149-
150152
# Additional environment variables
151153
env: []
152154
# - name: EXAMPLE_ENV

0 commit comments

Comments
 (0)