Prove the hotel install step by step
A hands-on lab. Every stage says what to run, what happens behind it, and how to check it really happened, so you can see each piece working on its own before trusting the whole flow.
| Part | Where | Proves |
|---|---|---|
| 1 | Your Mac | How a value gets from the site file into a manifest (render.sh) |
| 2 | Reading | Where each value lives and how it travels (in end-to-end.md) |
| 3 | A test VM | What install.sh installs |
| 4 | Test VM | The wizard up to approval, using the mock edge API |
| 5 | Test VM | Argo CD deploying everything (done by hand, like the wizard would) |
| 6 | Test VM | GitOps: a git change updates the site; a manual change gets undone |
| 7 | Test VM | Reset back to a clean machine |
| 8 | — | What can't be proven until coreapi exists |
New to the pieces (k3s, Argo CD, placeholders, the wizard)? Read
end-to-end.mdParts 0 and 0R first: the basics and a tour of the repo.
Part 1: The core idea, on your Mac (10 min)¶
Everything rests on one rule: git holds placeholders, the machine holds the values, and gitops/render.sh combines them.
1.1 Look at a placeholder in git¶
You'll see POSTGRES_PASSWORD: "${IBC_PG_PASSWORD}". That's all git ever has: no real password.
1.2 Make a pretend site file¶
On a real site, the wizard writes this file. For the test, write it yourself:
1.3 Render, inside the same Argo CD image the site uses¶
docker run --rm -v "$PWD":/r:ro -v /tmp/site.env:/s/site.env:ro -w /r -e IBC_SITE_ENV=/s/site.env --entrypoint bash quay.io/argoproj/argocd:v3.1.0 gitops/render.sh infrastructure/postgres | grep PASSWORD
Proof: it prints POSTGRES_PASSWORD: "<TEST_PASSWORD>". This is exactly what Argo CD does on every sync.
1.4 Prove it refuses a missing value¶
Render a component that needs values your file doesn't have:
docker run --rm -v "$PWD":/r:ro -v /tmp/site.env:/s/site.env:ro -w /r -e IBC_SITE_ENV=/s/site.env --entrypoint bash quay.io/argoproj/argocd:v3.1.0 gitops/render.sh infrastructure/valkey
Proof: it prints ERROR: unresolved values … ${IBC_VALKEY_PASSWORD} and outputs no YAML. So a site can never deploy a literal ${…}.
Part 2: Where values live, and how they travel (reading)¶
This is explained in end-to-end.md, with nothing to run:
- Part 0.3: the three places information lives
- Part 0.4: how a value is chosen (defaults → sites/<hotel>/ → the machine)
- Part D: the Postgres password, the domain and the license, traced through their whole journey
Read those, then continue with the VM.
Part 3: install.sh on a test VM (≈ 20 min)¶
Preparation:
- A fresh Debian 13 VM with a bridged network adapter (see Prepare a VM). Take a snapshot now, so you can go back.
- The branch you install from must be pushed to GitLab, because Argo CD pulls from there. This lab uses main.
3.1 Run it¶
For the tailnet key, type skip, or use a real one-time key (devops-handover.md 2.1).
3.2 Prove each thing it did¶
| Check | Command | Expect |
|---|---|---|
| k3s runs | kubectl get nodes |
One node, Ready |
| APISIX | kubectl get pods -n ingress-apisix |
All Running |
| cert-manager | kubectl get pods -n cert-manager |
All Running |
| Argo CD runs | kubectl -n argocd get pods |
All Running |
| The render plugin is attached | kubectl -n argocd get deploy argocd-repo-server -o jsonpath='{.spec.template.spec.containers[*].name}' |
argocd-repo-server ibc-render |
| Argo CD has no apps yet | kubectl -n argocd get applications |
No resources found |
| Argo CD can read git | kubectl -n argocd get secret ibc-repo -o jsonpath='{.data.url}' \| base64 -d |
Your repo URL |
| Site file started | sudo cat /etc/ibc/site.env |
Only IBC_GIT_URL, IBC_GIT_REVISION, IBC_REGISTRY_DOCKERCONFIG_B64 |
| Wizard service | systemctl status ibc-setup |
active (running) |
| Setup code | sudo cat /etc/ibc/setup-code |
6 digits |
| Tailnet (if you used a key) | tailscale ip -4 |
A 100.x address |
What you've proven: the machine is ready, but nothing site-specific exists yet. There's no domain and no passwords, and Argo CD is idle.
Part 4: The wizard, up to approval (mock edge API)¶
coreapi's edge API doesn't exist yet, so run the mock on the VM itself.
4.1 Start the mock and point the wizard at it¶
In a second terminal on the VM:
It printslicense: from …/setup-agent/dev/test-license.env: the lab license in the repo (the old bundle from the git history, lab only). On approval the mock hands it out, so authapi accepts it. To use another test license, add --license-file <file> (KEY=, PUBLIC_KEY=, PRIVATE_KEY= lines).
In the first terminal, add the mock's URL to the site file:
Use the VM's LAN IP, not 127.0.0.1: the check-in agent in Part 5.5 runs inside a pod, where 127.0.0.1 means the pod itself. The wizard reads the file on every request, so no restart is needed.
4.2 Fill in the wizard¶
From your Mac, open http://<VM-IP>:8800, enter the setup code, and fill in:
- company Test Hotel
- address testhotel
- your email
- an admin password (at least 10 characters, typed twice)
Press Install. The page shows "Waiting for approval".
4.3 Prove what happened when you pressed Install¶
| Check | Command | Expect |
|---|---|---|
| Values written | sudo grep -c IBC_ /etc/ibc/site.env |
About 25 lines: domain, org, all generated passwords |
| Passwords generated | sudo grep IBC_PG_PASSWORD /etc/ibc/site.env |
A random value |
| Copied into the cluster | kubectl -n argocd get secret ibc-site -o jsonpath='{.data.site\.env}' \| base64 -d \| grep IBC_DOMAIN |
IBC_DOMAIN='testhotel.castis.io' |
| Registered with the "API" | The mock's terminal | registration reg_… testhotel.castis.io … |
| No acme-dns login yet | sudo grep -c ACMEDNS_ACCOUNT /etc/ibc/site.env |
0 |
4.4 Play the Castis side: reject, then approve with a token¶
Reject it:
Result: The wizard shows the rejection with your reason, and a Retry button. Press Retry, and a new registration appears in the mock's terminal.
Approval is by token only. Create one (24 h, 3 uses):
Copy the token from the reply (e.g. <APPROVAL_TOKEN>), paste it into the wizard's Approval token box, and press Approve.
Proof: within a few seconds,
- sudo grep -c ACMEDNS_ACCOUNT /etc/ibc/site.env shows 1
- the wizard moves to "Certificate and local DNS"
4.5 Stop here¶
The mock's acme-dns login is fake unless you gave it a real one, so the certificate step waits forever. That's expected: the real account comes from the acme-dns server, which the mock only uses in the full test below.
Full test, certificate included (uses the acme-dns server from
playtelly-iac/acme-dns/, which is running): run the mock where it can reach acme-dns's/register(e.g. your laptop on the tailnet) and let it do coreapi's approval work:export CF_API_TOKEN=<Cloudflare token, DNS edit on castis.io>, thenpython3 setup-agent/dev/mock_edge_api.py --port 9900 --acmedns-register-url http://<acme-dns>:8080/register --cloudflare-zone castis.io. On approval (the token) it registers the site's acme-dns account and creates its_acme-challengeCNAME. Point the VM'sIBC_CLOUD_URLat the laptop's LAN IP, and before pressing Install addIBC_ACME_STAGING='true'to/etc/ibc/site.env(Let's Encrypt staging: high limits, so the test can be repeated). The certificate step then finishes, and the wizard carries on by itself: skip 4.5 and Part 5's manual steps.
Without a real account, stop the wizard so it doesn't keep retrying:
You can also check what reached cert-manager. It shows the fake account, keyed by the domain and the wildcard:
Part 5: Argo CD deploying everything (by hand)¶
The wizard's next steps are to create one root app and wait. Do the same by hand. The apps don't depend on the certificate, so this works without it.
5.1 See what Argo CD will get¶
This is the rendered root app. Note repoURL and targetRevision, which were filled in from the site file:
5.2 Hand it to Argo CD¶
5.3 Watch the waves¶
kubectl -n argocd get applications -w -o custom-columns='NAME:.metadata.name,WAVE:.metadata.annotations.argocd\.argoproj\.io/sync-wave,SYNC:.status.sync.status,HEALTH:.status.health.status'
Proof, in order:
1. ibc-root appears first, then the 20 child apps.
2. They turn Synced/Healthy wave by wave: site-base (-5), then postgres (-4), then zitadel, seaweedfs, etc. (-3), then … routes (2), finally ibc-agent (3).
3. authapi (-1) doesn't start until zitadel (-3) is finished.
This takes 10–20 minutes. If an app stays Degraded, run kubectl -n argocd describe application <name> and look under the conditions and events.
5.4 Prove the values landed¶
| Check | Command | Expect |
|---|---|---|
| Postgres got this site's password | kubectl -n db get secret postgres-secret -o jsonpath='{.data.POSTGRES_PASSWORD}' \| base64 -d |
Same as IBC_PG_PASSWORD in /etc/ibc/site.env |
| Git still has the placeholder | grep PASSWORD infrastructure/postgres/01-postgres-secret.yml |
${IBC_PG_PASSWORD} |
| Domain filled in | kubectl -n production get configmap coreapi-configmap -o yaml \| grep API_BASE_URL |
https://api.testhotel.castis.io |
| Databases created (hook) | kubectl -n db exec postgres-0 -- psql -U postgres -c '\l' |
authapi, coreapi, dummy listed |
| Zitadel PAT published (sidecar) | kubectl -n production get secret zitadel-pat |
Exists |
| authapi uses it | kubectl -n production get deploy authapi -o jsonpath='{.spec.template.spec.containers[0].envFrom}' |
Includes zitadel-pat |
| Owner is the Zitadel admin | kubectl -n zitadel get configmap zitadel-config -o yaml \| grep HUMAN_USERNAME |
Your email |
5.5 The hourly check-in (with the mock)¶
The ibc-agent CronJob runs every hour. Run it now instead of waiting:
Result: It prints ok: nothing new, and the mock's terminal shows check-in from reg_….
Now play Castis renewing the license:
Run the agent again (a new job name each time):
Proof:
- its log shows New license v2 and applied license v2
- kubectl -n argocd get configmap ibc-agent-status -o yaml shows the new expiry
- the authapi pod restarts by itself (AGE resets), because its config changed. With --license-file, the mock can't sign a new license, so it sends the same one again as v2: nothing changes and authapi does not restart
Rotating the acme-dns account works the same way: curl -X POST localhost:9900/admin/registrations/<id>/rotate-acme, run the agent again, and its log shows New acme-dns account v2.
5.6 Backup, and restore onto a second VM¶
Paused: Skip this for now: the backup is switched off (not in
gitops/apps/kustomization.yaml) until Castis decides where hotel backups are stored. The component stays ingitops/components/backup/; to switch it on, uncomment- backup.yamlingitops/apps/kustomization.yaml.
- Give the site a backup target (
devops-handover.md2.6). Any S3-compatible bucket works for a test. Don't use the site's own SeaweedFS, because the restore test wipes it. - Back up now: Result: It ends by listing a snapshot for your test hotel.
- Restore: on a second fresh VM (or this one after
./reset.sh), run./install.sh, then./restore.shwith the hotel's address prefix and the same four backup values (devops-handover.mdPart 5). Proof: kubectl -n argocd get applicationsgoes Synced + Healthykubectl -n db exec postgres-0 -- psql -U postgres -c '\l'lists the restored databases- the owner signs in with the same password as before
- the next check-in reaches the mock as the same registration
5.7 Optional: see it in the Argo CD UI¶
On the VM:
Open https://<VM-IP>:8080 and accept the self-signed warning. Sign in as admin, with the password from:
Part 6: GitOps, proven¶
6.1 Someone changes the cluster by hand → Argo CD undoes it¶
A few seconds later:
Proof: it's back. selfHeal: true in gitops/apps/coreapi.yaml puts it back to match git.
6.2 A change in git → the site updates by itself¶
- On your Mac, make a harmless change, e.g. add a label under
metadata.labelsinapplication/orgconsole/base/service.yml. Then commit and push tomain. - On the VM, Argo CD notices within about 3 minutes. To skip the wait, ask for a refresh:
- Check:
Proof: the label is there, and you never touched the VM except to look. That's how every site gets updates.
6.3 A per-hotel override → only that hotel changes, and restarts by itself¶
- Note coreapi's current stamp and pod age:
- On your Mac, create
sites/testhotel/site.env(your test address prefix) with one harmless override, e.g. an extra allowed redirect URL: Commit and push it tomain. - Refresh coreapi (or wait about 3 min):
Proof:
- kubectl -n production get configmap coreapi-configmap -o yaml | grep REDIRECT shows the extra URL
- the stamp from step 1 has a new value, and the coreapi pod is new (AGE reset)
So a config change reached one hotel and was picked up without a manual restart. Delete the file again afterwards.
6.4 Change a value on the machine → re-render (rare)¶
Site values change in the hotel's Secret argocd/ibc-site, not in git (after install it's the live copy; /etc/ibc/site.env may be older, because the check-in agent only updates the Secret):
1. Follow devops-handover.md → Change a value that lives on the machine.
2. Check that the affected pod restarted by itself (AGE reset).
Try it with something harmless. Don't use Postgres, Zitadel or the admin user: those are only read when they first start.
6.5 Survive a power cut¶
On the host Mac mini, run sudo host/macos/setup-host.sh "<VM name>" once (Prepare a VM, Mac host and power-cut tests). Then:
| Test | Do | Expect |
|---|---|---|
| VM stops | Inside the VM: sudo poweroff |
Within ~30 s the VM starts again (sudo host/macos/setup-host.sh --status on the Mac) |
| Mac reboots | On the Mac: sudo reboot, and don't log in |
A few minutes later: kubectl -n argocd get applications over the tailnet shows everything Synced + Healthy |
| Power cut | Pull the Mac mini's power cable, then plug it back in | The same, with nobody touching anything |
| Previous boot's logs | Inside the VM: journalctl -b -1 -n 50 |
Logs from before the reboot are still there |
Part 7: Reset¶
Proof:
- ls /etc/ibc → No such file or directory
- systemctl status ibc-setup → could not be found
- kubectl get nodes fails, because k3s is gone
Or just go back to the VM snapshot from Part 3.
Part 8: What you can't prove yet¶
| Step | Needs | Then prove it with |
|---|---|---|
| Real approval | The edge API in coreapi (edge-api.md) |
Create an approval token in the Console (instead of with curl to the mock) and enter it in the wizard |
| Real certificate | The edge API in coreapi, to create the site's acme-dns account and CNAME (the acme-dns server itself is running). Until then: the full test in 4.5 | kubectl get certificate -A shows Ready; the browser shows a valid lock |
| Local DNS for staff devices | The certificate step finishing (CoreDNS runs right after it) | From a phone on the site Wi-Fi, https://testhotel.castis.io opens |
| Wizard finish page + access email | All of the above | The wizard shows the sign-in details; coreapi emails the owner |
Once coreapi has the edge API, repeat Parts 3–4 without the mock and without stopping the wizard. It then does Part 5, and the Part 8 checks, by itself.