#!/usr/bin/env bash # One-time administrator bootstrap. Routine deployments use install.sh and limited RBAC. set -euo pipefail root=$(cd -- "$(dirname -- "$0")" && pwd) [[ $(kubectl config current-context) == kubernetes-admin@kubernetes ]] || { echo 'Wrong Kubernetes context' >&2; exit 1; } kubectl apply --dry-run=server -f "$root/namespace.yaml" kubectl apply -f "$root/namespace.yaml" for file in ci-deployer.yaml; do kubectl apply --dry-run=server -f "$root/$file" kubectl apply -f "$root/$file" done 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 "$root/render.sh" | kubectl apply --dry-run=server -f - "$root/render.sh" | kubectl apply -f - "$root/install.sh"