Files
factorio/bootstrap.sh
T

12 lines
694 B
Bash
Raw Normal View History

#!/usr/bin/env bash
2026-10-27 07:16:05 +01:00
# One-time administrator bootstrap for the existing namespace and runtime Secret.
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