2026-10-17 13:50:19 +02:00
|
|
|
#!/usr/bin/env bash
|
2026-10-27 07:16:05 +01:00
|
|
|
# One-time administrator bootstrap for the existing namespace and runtime Secret.
|
2026-10-17 13:50:19 +02:00
|
|
|
set -euo pipefail
|
|
|
|
|
root=$(cd -- "$(dirname -- "$0")" && pwd)
|
|
|
|
|
[[ $(kubectl config current-context) == kubernetes-admin@kubernetes ]] || { echo 'Wrong Kubernetes context' >&2; exit 1; }
|
|
|
|
|
kubectl apply -f "$root/namespace.yaml"
|
|
|
|
|
if ! kubectl -n factorio get secret factorio-runtime >/dev/null 2>&1; then
|
|
|
|
|
python3 - <<'PY' | kubectl create -f -
|
|
|
|
|
import base64,json,secrets
|
|
|
|
|
print(json.dumps({'apiVersion':'v1','kind':'Secret','metadata':{'name':'factorio-runtime','namespace':'factorio'},'type':'Opaque','data':{'rcon-password':base64.b64encode(secrets.token_urlsafe(32).encode()).decode()}}))
|
|
|
|
|
PY
|
|
|
|
|
fi
|