From c0da1a3f2a956498d749a7377089befdc3d2f997 Mon Sep 17 00:00:00 2001 From: Nicolas Bigler Date: Tue, 26 Nov 2024 18:37:07 +0100 Subject: [PATCH] Fix missing restAPI when using stackgres with OLM We need the Stackgres RestAPI for our maintenance. Without the RestAPI we won't be able to find the latest minor versions available. Unfortunately the RestAPI is not installed by default when using OLM and needs to be manually patched in the SGConfig. Signed-off-by: Nicolas Bigler --- component/vshn_postgres.jsonnet | 86 +++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/component/vshn_postgres.jsonnet b/component/vshn_postgres.jsonnet index 0bf721404..033439e90 100644 --- a/component/vshn_postgres.jsonnet +++ b/component/vshn_postgres.jsonnet @@ -40,6 +40,91 @@ local stackgresOperatorNs = kube.Namespace(params.stackgres.namespace) { }, }; +local sa = kube.ServiceAccount("stackgres-sgconfig-restapi-patcher") { + metadata+: { + namespace: params.stackgres.namespace, + }, +}; + +local role = kube.Role("stackgres-sgconfig-restapi-patcher") { + metadata+: { + namespace: params.stackgres.namespace, + }, + rules: [ + { + apiGroups: [ + "stackgres.io", + ], + resources: [ + "sgconfigs", + ], + verbs: [ + "get", + "list", + "watch", + "patch", + ], + }, + ], +}; + +local rolebinding = kube.RoleBinding("stackgres-sgconfig-restapi-patcher") { + metadata+: { + namespace: params.stackgres.namespace, + }, + roleRef: { + apiGroup: "rbac.authorization.k8s.io", + kind: "Role", + name: "stackgres-sgconfig-restapi-patcher", + }, + subjects: [ + { + kind: "ServiceAccount", + name: "stackgres-sgconfig-restapi-patcher", + }, + ], +}; + +local stackgresOperatorConfigPatch = kube.Job("stackgres-sgconfig-restapi-patcher") { + metadata+: { + namespace: params.stackgres.namespace, + }, + spec+: { + template+: { + spec+: { + restartPolicy: "Never", + serviceAccountName: "stackgres-sgconfig-restapi-patcher", + containers: [ + { + name: "patch-restapi", + image: params.images.kubectl.registry + "/" + params.images.kubectl.image + ":" + params.images.kubectl.tag, + command: [ + "sh", + "-c", + ], + args: [ + "cat <