All aboard Heap
kubectl for Heap, the Recurse Center's community cluster, logged in as you with your RC account. One command, nothing secret in the result.
Run this
On a laptop, from RC's network:
curl -fsSL https://<this site>/install.sh | shOn a machine with no browser, such as a shell on a Heap node, it picks the device flow by itself. To force it anywhere:
curl -fsSL https://<this site>/install.sh | sh -s -- --deviceIt's a shell script piped from the internet, so read it first: install.sh. --help lists the options.
What it does
- Finds
kubectland kubelogin, and installs whichever is missing. On a Mac with Homebrew that'sbrew install. Everywhere else it downloads a pinned version (kubectl v1.36.6, kubelogin v1.36.4), checks its SHA-256 against the one written in the script, and puts it in~/.local/bin. - Writes
~/.kube/heap.yaml. An older copy that differs is kept asheap.yaml.<timestamp>.bak. - Checks that Heap's API answers and that its certificate is Heap's.
- Runs
kubectl auth whoami, which logs you in.
It doesn't use sudo, edit your shell's rc files or touch ~/.kube/config. When it finishes:
export KUBECONFIG=~/.kube/heap.yaml
kubectl get pods -A
Put the export line in your shell's rc file so new terminals keep it. If you already use ~/.kube/config for other clusters, combine them with export KUBECONFIG=~/.kube/config:~/.kube/heap.yaml.
Logging in
With a browser, one opens on batchmate.id, which sends you to recurse.com and back. kubelogin catches the answer on localhost:8000, or 18000 if 8000 is taken.
The device flow prints a link instead. Open it anywhere (your phone works), log in to recurse.com if asked, and approve the code within 10 minutes. kubectl carries on within a few seconds.
Either way, whoami should show:
ATTRIBUTE VALUE
Username rc:<your RC id>
Groups [batchmate:recursers system:authenticated]
Admins also get heap:admins.
Tokens last an hour and kubelogin renews them quietly. After 8 hours you log in again. To log out, delete ~/.kube/cache/oidc-login.
What you can do
| Who | Kubernetes | Argo CD |
|---|---|---|
| Everyone who logs in | view in every namespace: pods, logs, events, Deployments, Ingresses. No Secrets. | get, sync, logs |
| An app's owners | edit in app-<name>: exec, port-forward, delete pods, read and write Secrets | as everyone |
| Admins | anything | anything |
An app's owners are the RC ids in its apps/<name>/owners.yaml in heap-k8s. Deploying is a PR there; kubectl is for looking at what's running, reading logs and debugging. Argo CD puts back whatever is in git, so a kubectl change to something it manages lasts until the next sync.
Without the script
The kubeconfig is the same file for everyone, so you can read heap.yaml or fetch it and do the rest yourself:
mkdir -p ~/.kube && curl -fsSL https://<this site>/heap.yaml -o ~/.kube/heap.yaml- Install kubelogin:
brew install kubelogin,kubectl krew install oidc-login, or a binary from its releases. - With krew's plugin, change
command: kubelogintocommand: kubectland add- oidc-loginas the first arg. - With no browser, add
- --grant-type=device-codeand- --skip-open-browserto the args. - Keep
--oidc-extra-scope=profile. It carries your RC id; without it you'rebatchmate:sub_…, and nothing granted to your RC id applies.
When it doesn't work
| You see | Meaning |
|---|---|
didn't answer from the installer, or a timeout from kubectl | You're not on RC's network. The API only answers there, and there's no tunnel. A VPN that carries all your traffic takes you off it even at the hub: turn it off and run the installer again. |
can't resolve k8s.cluster.recurse.com | Your resolver can't see it. A VPN's DNS is the usual cause. |
certificate Heap's CA didn't sign | Something between you and Heap answered instead of Heap: a captive portal, a proxy, a VPN. Or Heap was rebuilt and this site still has the old CA. Ask on Zulip. |
checksum mismatch | The download isn't what the script pins. Nothing was installed. Ask on Zulip. |
localhost:8080 was refused | KUBECONFIG isn't set in this shell. Run export KUBECONFIG=~/.kube/heap.yaml, or add it to your shell's rc file. |
kubectl: command not found | The installer put kubectl in ~/.local/bin, which isn't on your PATH. Add export PATH="$HOME/.local/bin:$PATH" to your shell's rc file. |
Forbidden | You're logged in, and nothing grants you that. |
Unauthorized | The token wasn't accepted. Delete ~/.kube/cache/oidc-login and log in again. |
invalid_request or a redirect error in the browser | kubelogin's port isn't 8000 or 18000, the only two redirects registered. |
unknown command "oidc-login" | krew's plugin isn't installed, or krew's bin isn't on your PATH. |
Username batchmate:sub_… | The kubeconfig doesn't ask for the profile scope. |
Anything else: #heap community cluster on Zulip.