comms(mas): make secret ensure job portable

This commit is contained in:
Brad Stein 2026-01-01 18:02:31 -03:00
parent 353f2e9210
commit 9d979a69fe

View File

@ -33,7 +33,7 @@ subjects:
apiVersion: batch/v1 apiVersion: batch/v1
kind: Job kind: Job
metadata: metadata:
name: mas-admin-client-secret-ensure-3 name: mas-admin-client-secret-ensure-4
namespace: comms namespace: comms
spec: spec:
backoffLimit: 2 backoffLimit: 2
@ -50,7 +50,7 @@ spec:
command: ["/bin/sh", "-c"] command: ["/bin/sh", "-c"]
args: args:
- | - |
set -euo pipefail set -eu
umask 077 umask 077
dd if=/dev/urandom bs=32 count=1 2>/dev/null | od -An -tx1 | tr -d ' \n' > /work/client_secret dd if=/dev/urandom bs=32 count=1 2>/dev/null | od -An -tx1 | tr -d ' \n' > /work/client_secret
volumeMounts: volumeMounts:
@ -62,8 +62,8 @@ spec:
command: ["/bin/sh", "-c"] command: ["/bin/sh", "-c"]
args: args:
- | - |
set -euo pipefail set -eu
if kubectl -n comms get secret mas-admin-client -o jsonpath='{.data.client_secret}' 2>/dev/null | grep -q .; then if [ -n "$(kubectl -n comms get secret mas-admin-client -o jsonpath='{.data.client_secret}' 2>/dev/null || true)" ]; then
exit 0 exit 0
fi fi
secret="$(cat /work/client_secret)" secret="$(cat /work/client_secret)"