Skip to content

Commit 2e39888

Browse files
authored
K8SPG-375: Merge extension installer image into operator (#573)
* K8SPG-375: Merge extension installer image into operator * fix tests * fix openshift * detect openshift * don't use hardcoded postgres version * don't use hardcoded postgres version
1 parent fafb018 commit 2e39888

23 files changed

+185
-378
lines changed

build/extension-installer/Dockerfile

Lines changed: 0 additions & 41 deletions
This file was deleted.

build/postgres-operator/Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ RUN mkdir -p build/_output/bin \
1515
go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH" \
1616
-o build/_output/bin/postgres-operator \
1717
./cmd/postgres-operator \
18-
&& cp -r build/_output/bin/postgres-operator /usr/local/bin/postgres-operator
18+
&& CGO_ENABLED=$CGO_ENABLED GOOS=$GOOS GO_LDFLAGS=$GO_LDFLAGS \
19+
go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH" \
20+
-o build/_output/bin/extension-installer \
21+
./cmd/extension-installer \
22+
&& cp -r build/_output/bin/postgres-operator /usr/local/bin/postgres-operator \
23+
&& cp -r build/_output/bin/extension-installer /usr/local/bin/extension-installer
1924

2025

2126
RUN ./bin/license_aggregator.sh ./cmd/...; \
@@ -34,7 +39,9 @@ RUN microdnf update -y && microdnf clean all -y
3439
COPY licenses /licenses
3540

3641
COPY --from=go_builder /usr/local/bin/postgres-operator /usr/local/bin
42+
COPY --from=go_builder /usr/local/bin/extension-installer /usr/local/bin
3743
COPY --from=go_builder /licenses /licenses
44+
COPY build/postgres-operator/install-extensions.sh /usr/local/bin
3845

3946
USER 2
4047

cmd/postgres-operator/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ func addControllersToManager(ctx context.Context, mgr manager.Manager) error {
167167
Platform: detectPlatform(ctx, mgr.GetConfig()),
168168
KubeVersion: getServerVersion(ctx, mgr.GetConfig()),
169169
CrunchyController: cm.Controller(),
170+
IsOpenShift: isOpenshift(ctx, mgr.GetConfig()),
170171
}
171172
if err := pc.SetupWithManager(mgr); err != nil {
172173
return err

deploy/cr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ spec:
283283
# work_mem: 2MB
284284

285285
# extensions:
286-
# image: perconalab/percona-postgresql-operator:main-ext-installer
286+
# image: perconalab/percona-postgresql-operator:main
287287
# imagePullPolicy: Always
288288
# storage:
289289
# type: s3

e2e-tests/functions

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ get_cr() {
154154
;;
155155
custom-extensions)
156156
yq eval '
157-
.spec.postgresVersion = 15
158-
| .spec.image = "'${IMAGE_BASE}:k8spg-375-ppg15-postgres'"
159-
| .spec.extensions.image = "'${IMAGE_EXT_INSTALLER}'"
157+
.spec.extensions.image = "'${IMAGE}'"
160158
| .spec.extensions.imagePullPolicy = "Always"
161159
| .spec.extensions.storage = {"type": "s3", "bucket": "pg-extensions", "region": "eu-central-1", "secret": {"name": "aws-s3-secret"}}
162160
' "${TEMP_DIR}/cr.yaml" \

e2e-tests/tests/custom-extensions/02-assert.yaml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ spec:
2222
- name: postgres-startup
2323
- command:
2424
- /usr/local/bin/relocate-extensions.sh
25-
env:
26-
- name: PG_VERSION
27-
value: "15"
2825
name: extension-relocator
2926
resources: {}
3027
volumeMounts:
@@ -42,11 +39,8 @@ spec:
4239
- name: STORAGE_BUCKET
4340
value: pg-extensions
4441
- name: INSTALL_EXTENSIONS
45-
value: pg_cron-pg15-1.6.1
4642
- name: PG_VERSION
47-
value: "15"
4843
- name: PGDATA_EXTENSIONS
49-
value: /pgdata/extension/15
5044
envFrom:
5145
- secretRef:
5246
name: aws-s3-secret
@@ -55,12 +49,8 @@ spec:
5549
volumeMounts:
5650
- mountPath: /pgdata
5751
name: postgres-data
58-
- mountPath: /usr/pgsql-15/share/extension
59-
name: postgres-data
60-
subPath: extension/15/usr/pgsql-15/share/extension
61-
- mountPath: /usr/pgsql-15/lib
62-
name: postgres-data
63-
subPath: extension/15/usr/pgsql-15/lib
52+
- name: postgres-data
53+
- name: postgres-data
6454
- mountPath: /tmp
6555
name: tmp
6656
- name: nss-wrapper-init

e2e-tests/tests/custom-extensions/04-assert.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ data:
4343
pg_cron
4444
pg_freespacemap
4545
pg_prewarm
46+
pg_repack
4647
pg_stat_monitor
4748
pg_stat_statements
4849
pg_surgery

e2e-tests/tests/custom-extensions/05-assert.yaml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ spec:
2222
- name: postgres-startup
2323
- command:
2424
- /usr/local/bin/relocate-extensions.sh
25-
env:
26-
- name: PG_VERSION
27-
value: "15"
2825
name: extension-relocator
2926
resources: {}
3027
volumeMounts:
@@ -42,11 +39,8 @@ spec:
4239
- name: STORAGE_BUCKET
4340
value: pg-extensions
4441
- name: INSTALL_EXTENSIONS
45-
value: pg_cron-pg15-1.6.1,timescaledb-pg15-2.11.2
4642
- name: PG_VERSION
47-
value: "15"
4843
- name: PGDATA_EXTENSIONS
49-
value: /pgdata/extension/15
5044
envFrom:
5145
- secretRef:
5246
name: aws-s3-secret
@@ -55,20 +49,17 @@ spec:
5549
volumeMounts:
5650
- mountPath: /pgdata
5751
name: postgres-data
58-
- mountPath: /usr/pgsql-15/share/extension
59-
name: postgres-data
60-
subPath: extension/15/usr/pgsql-15/share/extension
61-
- mountPath: /usr/pgsql-15/lib
62-
name: postgres-data
63-
subPath: extension/15/usr/pgsql-15/lib
52+
- name: postgres-data
53+
- name: postgres-data
6454
- mountPath: /tmp
6555
name: tmp
6656
- name: nss-wrapper-init
6757
status:
68-
observedGeneration: 3
58+
observedGeneration: 2
6959
replicas: 1
7060
updatedReplicas: 1
7161
readyReplicas: 1
62+
availableReplicas: 1
7263
---
7364
apiVersion: pgv2.percona.com/v2
7465
kind: PerconaPGCluster
@@ -85,4 +76,4 @@ status:
8576
size: 3
8677
ready: 3
8778
size: 3
88-
state: ready
79+
state: ready

e2e-tests/tests/custom-extensions/05-install-timescaledb.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)