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 <