Skip to content

Commit ebf5bd2

Browse files
authored
Merge pull request #344 from projectsyn/deps/adjust-bitnami
Switch to `bitnamilegacy` images for builtin Postgresql
2 parents 452b6ba + 11b021f commit ebf5bd2

File tree

4 files changed

+65
-8
lines changed

4 files changed

+65
-8
lines changed

class/defaults.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ parameters:
5252
tag: 1.32
5353
postgresql:
5454
registry: docker.io
55-
repository: bitnami/postgresql
55+
repository: bitnamilegacy/postgresql
5656
tag: 15.10.0-debian-12-r2
5757
bitnamishell:
5858
registry: docker.io
59-
repository: bitnami/os-shell
59+
repository: bitnamilegacy/os-shell
6060
tag: 12-debian-12-r49
6161
charts:
6262
keycloakx:

postprocess/postgresql.jsonnet

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,67 @@ local files_in_dir = std.native('list_dir')(dir_path, true);
1313
/* Remove file_extension from file list */
1414
local files = [ std.strReplace(file, file_extension, '') for file in files_in_dir ];
1515

16+
local bitnami_ready =
17+
'[ -f /opt/bitnami/postgresql/tmp/.initialized ] || [ -f /bitnami/postgresql/.initialized ]\n';
18+
19+
// NOTE(sg): The Helm chart has custom logic to inject the `bitnami_ready`
20+
// string in the postgres container's readiness probe when it's rendered with
21+
// an image that contains exactly `bitnami/`. We mimic the Helm chart's
22+
// behavior for images that contain `bitnamilegacy/` here since those still
23+
// are bitnami images and will have the bitnami special readiness indication
24+
// file.
25+
local patchReadinessProbe(obj) =
26+
if std.startsWith(params.images.postgresql.repository, 'bitnamilegacy/')
27+
&& obj.kind == 'StatefulSet'
28+
&& obj.metadata.name == 'keycloak-postgresql'
29+
then
30+
local containers = obj.spec.template.spec.containers;
31+
assert
32+
std.length(containers) == 1 :
33+
'Expected builtin postgres statefulset to have a single container';
34+
// extract the readiness probe command
35+
local rcommand = containers[0].readinessProbe.exec.command;
36+
// extract the sh -c -e prefix
37+
local shell = rcommand[0:std.length(rcommand) - 1];
38+
assert
39+
shell[0] == '/bin/sh' :
40+
'expected readiness command to start with\n /bin/sh';
41+
// patch the command string with a second line checking for the bitnami
42+
// initialized file.
43+
local cmd = rcommand[std.length(rcommand) - 1];
44+
assert
45+
std.startsWith(cmd, 'exec pg_isready') :
46+
'expected readiness probe to use `exec pg_isready`';
47+
local patched_cmd = [ cmd + bitnami_ready ];
48+
obj {
49+
spec+: {
50+
template+: {
51+
spec+: {
52+
containers: [
53+
containers[0] {
54+
readinessProbe+: {
55+
exec: {
56+
// set the patched command
57+
command: shell + patched_cmd,
58+
},
59+
},
60+
},
61+
],
62+
},
63+
},
64+
},
65+
}
66+
else
67+
obj;
68+
1669
{
1770
[file]:
1871
if params.postgresql_helm_values.enabled
19-
then com.yaml_load(std.extVar('output_path') + '/' + file + file_extension)
20-
else []
72+
then
73+
patchReadinessProbe(
74+
com.yaml_load(std.extVar('output_path') + '/' + file + file_extension)
75+
)
76+
else
77+
[]
2178
for file in files
2279
}

tests/golden/builtin/builtin/builtin/01_keycloak_helmchart/postgresql/templates/primary/statefulset.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ spec:
9292
value: error
9393
- name: POSTGRESQL_SHARED_PRELOAD_LIBRARIES
9494
value: pgaudit
95-
image: docker.io/bitnami/postgresql:15.10.0-debian-12-r2
95+
image: docker.io/bitnamilegacy/postgresql:15.10.0-debian-12-r2
9696
imagePullPolicy: IfNotPresent
9797
livenessProbe:
9898
exec:
@@ -162,7 +162,7 @@ spec:
162162
cp /tmp/certs/* /opt/bitnami/postgresql/certs/
163163
chown -R 1001:1001 /opt/bitnami/postgresql/certs/
164164
chmod 600 /opt/bitnami/postgresql/certs/tls.key
165-
image: docker.io/bitnami/os-shell:12-debian-12-r49
165+
image: docker.io/bitnamilegacy/os-shell:12-debian-12-r49
166166
imagePullPolicy: IfNotPresent
167167
name: init-chmod-data
168168
resources:

tests/golden/openshift-postgres/openshift-postgres/openshift-postgres/01_keycloak_helmchart/postgresql/templates/primary/statefulset.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ spec:
9292
value: error
9393
- name: POSTGRESQL_SHARED_PRELOAD_LIBRARIES
9494
value: pgaudit
95-
image: docker.io/bitnami/postgresql:15.10.0-debian-12-r2
95+
image: docker.io/bitnamilegacy/postgresql:15.10.0-debian-12-r2
9696
imagePullPolicy: IfNotPresent
9797
livenessProbe:
9898
exec:
@@ -152,7 +152,7 @@ spec:
152152
- |
153153
cp /tmp/certs/* /opt/bitnami/postgresql/certs/
154154
chmod 600 /opt/bitnami/postgresql/certs/tls.key
155-
image: docker.io/bitnami/os-shell:12-debian-12-r49
155+
image: docker.io/bitnamilegacy/os-shell:12-debian-12-r49
156156
imagePullPolicy: IfNotPresent
157157
name: copy-certs
158158
resources:

0 commit comments

Comments
 (0)