Hardening guide
title: IBC hotel hardening description: How the ibc-iac hotel stack was hardened, part by part: problem, steps, checks and how to repeat it on another hotel. audience: internal type: explanation owner: platform-team last_reviewed: 2026-11-19
A complete record of how the hotel stack was hardened: for each part, the problem, the steps taken, how it was checked, and how to repeat it on another hotel. Everything is on main of ibc-iac.
1. Overview¶
- Autoscaling for the services, and resource requests tuned to fit the node.
- Kyverno with an image-signature policy in Deny mode.
- A
prerequisite.shthat is safe to run again. - A streamer that waits for storage before it starts.
- Cluster access through
sudo, and scripts and docs in folders. - A tool to change passwords safely, and an audit log of who did what.
- A per-hotel token-signing key instead of one shared key.
- A plain-language
--helpfor every script.
Scripts reach a hotel only when someone runs git pull there. Argo CD deploys the manifests by itself.
2. Conventions and checks¶
- Run scripts as your own user (they call
sudothemselves).show-secrets.shandaudit-log.shneedsudoin front. Every script has--help. - Type
sudo kubectl ...(kubectl runs throughsudowith root's kubeconfig; see section 7). - After any change, check the hotel:
| Script | Purpose |
|---|---|
./install.sh |
set up a new site |
./prerequisite.sh |
base software, certificate, DNS (configured with environment variables) |
./restore.sh |
rebuild a hotel from a backup |
./reset.sh |
erase the installation (asks you to type yes) |
./scripts/change-ip.sh |
after the server's IP changes |
./scripts/change-password.sh |
change passwords |
sudo ./scripts/show-secrets.sh |
show every password (logged) |
sudo ./scripts/audit-log.sh |
read the audit log |
3. Autoscaling and resource requests¶
Problem. Only coreapi had an autoscaler, and the demo node was at about 95% of its memory requests, so rollouts could sit Pending.
Steps taken
1. Checked every service in application/ for an HPA and decided what needs one. Hotel traffic is low, so 1 to 2 replicas is enough. A PodDisruptionBudget is pointless for single-replica services (it would only block kubectl drain).
2. Reviewed cdn/ and infrastructure/: stateful or single-replica, so no HPA or PDB there.
3. Added overlays/hpa.yml to six more services (authapi, conciergeguestapp, orgconsole, playoutadmin, tellyid, tellyboardadmin) and enabled the line in each overlays/kustomization.yaml.
4. Set the targets to CPU 70% (coreapi 80%) and memory 80% (coreapi 85%). An HPA percentage is usage divided by the request, so the requests were adjusted as well: frontend memory request raised to 128Mi, orgconsole CPU and memory raised, coreapi CPU request lowered (500m to 250m), VerneMQ (250m to 100m) and tusd (200m to 100m) lowered.
Check. kubectl kustomize application/<service>/overlays renders one HorizontalPodAutoscaler per service. On the hotel, kubectl get hpa -A lists seven with real TARGETS.
Note. An HPA needs metrics-server. When it is unhealthy, the HPAs simply stay at their current size.
4. Image-signature check (Kyverno)¶
Goal. Refuse any registry.nexus.castis.io/playtelly/* image that is not signed with our key (playtellyinternal is excluded).
Steps taken
1. Added kyverno/kyverno-values.yaml: images from Nexus, the pull secret, one admission-controller replica, background controllers off.
2. Added Step 6b to prerequisite.sh: namespace, pull secret, helm install of the pinned chart (versions.env), then wait for the pods and the CRD imagevalidatingpolicies.policies.kyverno.io. It skips what is already installed.
3. Added the policy verify-playtelly-image-signature as an Argo CD app in sync wave -6: a cosign public key, failurePolicy: Ignore (a Kyverno outage never blocks a deployment), and a matchConditions rule that skips playtellyinternal.
4. Started in Audit, checked the policy reports, then switched to Deny in both ibc-iac and playtelly-iac, and updated the wiki security guide.
Check
kubectl get pods -n kyverno
kubectl get imagevalidatingpolicy
kubectl get policyreport -A --no-headers | awk '$6>0 || $8>0' # FAIL / ERROR columns: nothing
Notes. Mirror the Kyverno images and chart into Nexus first. A hotel that follows main before Kyverno is installed shows the kyverno-policies app failing (missing CRD). The Deny test itself (an unsigned image refused) is still to be done.
5. A prerequisite.sh that is safe to re-run¶
Problem. Someone ran PREREQ_PHASE=site by hand with the default domain. It replaced the ClusterIssuer and the Certificate with the placeholder your-domain.example.com.
Steps taken
1. Repaired the live system: re-applied the issuer and the certificate with the real domain, and the Certificate returned to READY True.
2. Made the script follow the saved site values (/etc/ibc/site.env) whenever the site phase can run, refuse a domain that differs from the saved one, and refuse the placeholder domain (escape hatches: ALLOW_PLACEHOLDER_DOMAIN=1, IBC_SITE_ENV=none).
3. Added a warning when the node IP changes (remembered in /etc/ibc/node-ip), masked the APISIX admin key in the output, stopped a false alarm about port 53 (it is our own lan-coredns), and capped the Step 4 wait at about 5 minutes.
4. Tested six cases with a stub (saved values used, mismatch refused, placeholder refused, and so on), and re-ran the script on two boxes. On the playtelly box it installed Kyverno from scratch, which proved Step 6b.
Check. A plain ./prerequisite.sh on an installed hotel prints Using the domain saved in /etc/ibc/site.env: <domain>, and each step says "already installed, skipping".
What the re-runs showed
- The Debian updater can hold the apt lock for several minutes; the script just waits.
- When a hotel's IP changed from .76 to .78 (DHCP), pods lost the API for a minute or two: CoreDNS, metrics-server, Kyverno and the ingress controller recovered or needed a restart. Give the server a DHCP reservation, and run ./scripts/change-ip.sh after a change.
6. Streamer startup order¶
Problem. After a server restart the streamer sometimes worked badly. Restarting only the streamer fixed it, so it had started before cproxy and SeaweedFS were ready.
Steps taken
1. Read the chain streamer, cproxy, SeaweedFS and found nothing that enforces the order after a reboot.
2. Added an init container wait-for-cproxy to cdn/streamer/03-deployment.yaml. It calls http://cproxy.cdn.svc.cluster.local:8080/store/playtelly until the answer is below 500 (a healthy path returns 200), and gives up after 5 minutes so live streams are not blocked by a storage outage.
3. Tested on the laptop. A rolling update there sat Pending for memory. A Recreate strategy was considered and dropped, because many services follow that file.
Check. kubectl logs -n cdn deploy/streamer -c wait-for-cproxy shows answers (HTTP 200). Starting streamer.
7. Cluster access through sudo, and the folder layout¶
Problem. prerequisite.sh copied the k3s admin kubeconfig into the installing user's home folder, so anyone with that file was a full cluster admin, with no name in any log.
Steps taken
1. Added scripts/lib/ibc-kube.sh: inside a script, kubectl and helm run as sudo env KUBECONFIG=/etc/rancher/k3s/k3s.yaml .... The default is IBC_KUBE_ACCESS=sudo; copy brings back the old ~/.kube/config.
2. Converted install.sh, restore.sh, prerequisite.sh, change-ip.sh, reset.sh and the partner enrollment (a Python program, which cannot see shell functions, now calls sudo kubectl itself).
3. Moved the day-to-day tools to scripts/ (helpers in scripts/lib/) and the guides to docs/; the installers stay in the root. A small tool rewrote every link and ./script path, and every Markdown link was checked.
Check. mv ~/.kube/config ~/.kube/config.bak, then ./scripts/change-password.sh --dry-run valkey and sudo kubectl get nodes still work. Put the file back afterwards.
8. Password change tool¶
Design. A site's passwords live in two places that must change together: the Secret argocd/ibc-site (the live copy Argo CD reads) and /etc/ibc/site.env. Argo CD's render step (gitops/render.sh) stamps each workload with a hash of its values, so a changed value restarts exactly what uses it.
Steps taken
1. Built scripts/change-password.sh: a menu of eight items that shows every password first, asks for a reason and a typed confirmation, saves the old value (root only, the last 10 are kept), writes both copies, restarts the repo server, hard-refreshes the apps and waits for the pods to roll.
2. Refused on purpose: the Postgres and Zitadel passwords, the master keys and the encryption key (they are read at first start, or would make data unreadable).
3. Added: typing your own value with a live checklist (or Enter for a random one), several items in one go, --dry-run, and --rollback.
4. Tested in a Debian container against a fake cluster, and on a pseudo-terminal for the live prompt.
5. Tested on the demo laptop: Valkey (about 4 minutes, mostly Argo CD noticing), PSK, S3 (about 7 minutes, three workloads restart), the JWT key, and a rollback listing. A fingerprint check proved Valkey and coreapi held the same new password.
How to use it
./scripts/change-password.sh # menu (shows all passwords first)
./scripts/change-password.sh valkey --reason "ticket 123"
./scripts/change-password.sh valkey mqtt psk # several in one go
./scripts/change-password.sh --all --reason "rotation"
./scripts/change-password.sh --dry-run valkey # preview, changes nothing
./scripts/change-password.sh --rollback # undo ONE earlier change
s3, valkey, mqtt, mqtt_webos, psk, jwt_access, jwt_refresh, jwt_rsa.
- Rules for a typed value: letters and digits only; Valkey and MQTT 12-128 characters; S3 keys 16-64; PSK and JWT secrets 32-128; at least 6 different characters; not the current value.
- Rollback undoes one change or one batch. It never undoes everything.
Notes. Argo CD takes up to about 3 minutes to notice a change; the script asks for a refresh every minute while it waits. MQTT after a change is still to be verified on a real cluster.
9. Audit log¶
Goal. Know who viewed or changed passwords, and who ran the scripts that change the machine.
Steps taken
1. scripts/lib/ibc-audit.sh writes one JSON line per event (when, who, from where, what, result, reason, 8-character fingerprints, never a value) to /var/log/ibc/audit.log and to the journal.
2. Fail-closed: a change writes started first and does nothing if it cannot.
3. scripts/audit-log.sh: filters, --csv, --out FILE (mode 600, with a hash), --check (file against journal), --follow (live, survives a rotation) and --newest-first.
4. Retention: prerequisite.sh Step 0b installs /etc/logrotate.d/ibc-audit (monthly, 12 kept, compressed). The viewer reads the rotated files too. A forced rotation on the laptop proved it.
5. Script runs: install.sh, prerequisite.sh, restore.sh, reset.sh and change-ip.sh write run lines (started, then ok, failed or cancelled). A nested run is recorded once. reset.sh, restore.sh and change-ip.sh refuse to run if the log cannot be written; reset.sh never deletes /var/log/ibc.
Recorded: viewing the passwords, changing or rolling back a password, and running the five scripts above. Never recorded: password values, --help, --dry-run.
How to use it
sudo ./scripts/audit-log.sh # last 50, as a table
sudo ./scripts/audit-log.sh --since 7d --user alice
sudo ./scripts/audit-log.sh --action run # who ran which script
sudo ./scripts/audit-log.sh --newest-first
sudo ./scripts/audit-log.sh -f --tail 0 # live, like tail -f
sudo ./scripts/audit-log.sh --since 30d --csv --out ~/audit.csv
sudo ./scripts/audit-log.sh --check # has the log been edited?
/var/log/ibc/audit.log (root only), with a second copy in the journal (journalctl -t ibc-audit).
10. Per-hotel JWT signing key¶
Problem found. application/authapi/overlays/secret.yml held one RSA private key, written in the file since the first commit, the same for every hotel and for the cloud production (playtelly-iac). Anyone with the repo could forge a sign-in token for any hotel.
Steps taken (in this order, so nothing broke)
1. The setup wizard now generates a key per site (IBC_JWT_RSA_PRIVATE_KEY, RSA-2048, base64 of the PKCS#8 PEM).
2. Added the jwt_rsa item to the password tool, so an existing hotel can create its own key once: ./scripts/change-password.sh jwt_rsa --reason "per-hotel JWT key". Nothing restarted at this stage.
3. After the hotels had a key, the manifest was switched to "${IBC_JWT_RSA_PRIVATE_KEY}" and the literal key removed. A render test showed that a hotel without the key fails to render (the running pods keep running).
4. On the laptop: authapi restarted once, the application is Synced and Healthy, and people sign in again once.
Check. sudo ./scripts/show-secrets.sh | grep "JWT RSA" says set, fingerprint ....
Still open. The old key stays in git history and in playtelly-iac prod: replace it there. Roll main, then canary, then stable, only when every hotel on that branch shows the key as set.
11. Help texts and documentation¶
Every script now has a plain-language --help, written to the CLI guidelines (clig.dev and Fuchsia's CLI help rules): USAGE and EXAMPLES first, then what it does, options, what to expect, exit codes, and a next step. It fits in 78 columns and explains the jargon. prerequisite.sh, restore.sh and reset.sh take no options and refuse any other argument, so --help never starts an install or a wipe. Also added: CLAUDE.md (state, rules, open items, gotchas), the runbook in docs/devops-handover.md, and demo/ kept out of partner releases (.releaseignore).
12. Roll-out checklist for a hotel¶
cd ~/ibc-iac && git pull(see the first item in Troubleshooting if it fails).- Check the hotel has its JWT key:
sudo ./scripts/show-secrets.sh | grep "JWT RSA". If it saysNOT SET, run./scripts/change-password.sh jwt_rsa --reason "per-hotel JWT key". - Install the audit-log rotation:
PREREQ_PHASE=base ./prerequisite.sh, or the manual commands indocs/devops-handover.md, thensudo logrotate -d /etc/logrotate.d/ibc-audit. - Run the checks in section 2.
- Remove the old
~/.kube/configonce the new scripts are in use (IBC_KUBE_ACCESS=copybrings the old way back if needed). - Move on a branch at a time:
main(lab),canary(pilot),stable(everyone), only after the hotels on the branch pass the checks.
13. Troubleshooting¶
git pull: "Missing or invalid credentials" andvscode-git ... ECONNREFUSED. A stale VS Code credential helper. Open a new terminal in the connected VS Code window, or rununset GIT_ASKPASS VSCODE_GIT_ASKPASS_NODE VSCODE_GIT_ASKPASS_MAIN VSCODE_GIT_ASKPASS_EXTRA_ARGS VSCODE_GIT_IPC_HANDLEand use a GitLab access token. Also check that Argo CD can still pull:sudo kubectl get applications -n argocd.- A change waits for "Argo CD to roll". Argo CD can take about 3 minutes to notice. If it never rolls:
sudo kubectl -n argocd annotate applications --all argocd.argoproj.io/refresh=hard --overwrite, then check the application status. - A pod is
PendingwithInsufficient memory. The scheduler counts requests, not usage. On a small node a rolling update needs room for both the old and the new pod. - CoreDNS, metrics-server or the ingress controller are not ready after a k3s restart or an IP change. Give them a minute or two. If they stay down, restart the ingress controller:
kubectl -n ingress-apisix rollout restart deploy apisix-ingress-controller. prerequisite.shsits at "Waiting for cache lock". Debian's updater holds the apt lock; it continues by itself.ibc-agentpods showError. The agent is an hourly job. An oldErrorafter a restart (for example a DNS blip) is harmless;Completedis normal. With no edge API yet it logsskipped: no edge API URL or registration yet.rendererror:unresolved values ... ${IBC_JWT_RSA_PRIVATE_KEY}. The hotel has no JWT key yet; see step 2 of the roll-out checklist.
14. Reviews, decisions and what is next¶
Decisions
- A central secret manager is not needed yet. It depends on the edge API in coreapi, which does not exist. The names (IBC_*) and the audit line format carry over later.
- The Kubernetes API audit is postponed; the sudo log already names who ran sudo kubectl.
- Findings: the shared RSA key (fixed above), and tokens left in demo/ (rotate them).
Next, in order
1. Lab-VM test of a fresh install.sh and restore.sh.
2. Turn backups on (gitops/apps/backup.yaml) and test the restore.
3. Make hotels follow canary and stable; replace the old key in playtelly-iac.
4. Hardening before a real hotel: a firewall, a per-site APISIX admin key, the setup wizard closed after install.
5. Ship the audit log off the box.