From a828b602d69fd581210750c5130d64d5bfa01d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Wed, 16 Aug 2023 22:41:41 +0300 Subject: [PATCH] freescout: Add Job for resetting OIDC config --- freescout/reset-oidc-config.yaml | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 freescout/reset-oidc-config.yaml diff --git a/freescout/reset-oidc-config.yaml b/freescout/reset-oidc-config.yaml new file mode 100644 index 0000000..e880bd3 --- /dev/null +++ b/freescout/reset-oidc-config.yaml @@ -0,0 +1,50 @@ +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: reset-oidc-config +spec: + template: + spec: + volumes: + - name: tmp + emptyDir: {} + initContainers: + - name: jq + image: alpine/k8s:1.24.16@sha256:06f8942d87fa17b40795bb9a8eff029a9be3fc3c9bcc13d62071de4cc3324153 + imagePullPolicy: IfNotPresent + volumeMounts: + - mountPath: /tmp + name: tmp + envFrom: + - secretRef: + name: oidc-client-freescout-owner-secrets + command: + - /bin/bash + - -c + - rm -fv /tmp/update.sql; + jq '{"name":"oauth.client_id","value":$ENV.OIDC_CLIENT_ID} | "UPDATE options SET value=\(.value|tostring|@sh) WHERE name=\(.name|tostring|@sh) LIMIT 1;"' -n -r >> /tmp/update.sql; + jq '{"name":"oauth.client_secret","value":$ENV.OIDC_CLIENT_SECRET} | "UPDATE options SET value=\(.value|tostring|@sh) WHERE name=\(.name|tostring|@sh) LIMIT 1;"' -n -r >> /tmp/update.sql; + jq '{"name":"oauth.auth_url","value":$ENV.OIDC_GATEWAY_AUTH_URI} | "UPDATE options SET value=\(.value + "?scope=openid+profile" |tostring|@sh) WHERE name=\(.name|tostring|@sh) LIMIT 1;"' -n -r >> /tmp/update.sql; + jq '{"name":"oauth.token_url","value":$ENV.OIDC_GATEWAY_TOKEN_URI} | "UPDATE options SET value=\(.value|tostring|@sh) WHERE name=\(.name|tostring|@sh) LIMIT 1;"' -n -r >> /tmp/update.sql; + jq '{"name":"oauth.user_url","value":$ENV.OIDC_GATEWAY_USERINFO_URI} | "UPDATE options SET value=\(.value|tostring|@sh) WHERE name=\(.name|tostring|@sh) LIMIT 1;"' -n -r >> /tmp/update.sql; + cat /tmp/update.sql + containers: + - name: mysql + image: mysql + imagePullPolicy: IfNotPresent + volumeMounts: + - mountPath: /tmp + name: tmp + env: + - name: MYSQL_PWD + valueFrom: + secretKeyRef: + name: freescout-secrets + key: DB_PASS + command: + - /bin/bash + - -c + - mysql -u kspace_freescout kspace_freescout -h 172.20.36.1 -p${MYSQL_PWD} < /tmp/update.sql + restartPolicy: OnFailure + backoffLimit: 4