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 | sh

On 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 -- --device

It's a shell script piped from the internet, so read it first: install.sh. --help lists the options.

What it does

  1. Finds kubectl and kubelogin, and installs whichever is missing. On a Mac with Homebrew that's brew 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.
  2. Writes ~/.kube/heap.yaml. An older copy that differs is kept as heap.yaml.<timestamp>.bak.
  3. Checks that Heap's API answers and that its certificate is Heap's.
  4. 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

WhoKubernetesArgo CD
Everyone who logs inview in every namespace: pods, logs, events, Deployments, Ingresses. No Secrets.get, sync, logs
An app's ownersedit in app-<name>: exec, port-forward, delete pods, read and write Secretsas everyone
Adminsanythinganything

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

When it doesn't work

You seeMeaning
didn't answer from the installer, or a timeout from kubectlYou'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.comYour resolver can't see it. A VPN's DNS is the usual cause.
certificate Heap's CA didn't signSomething 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 mismatchThe download isn't what the script pins. Nothing was installed. Ask on Zulip.
localhost:8080 was refusedKUBECONFIG isn't set in this shell. Run export KUBECONFIG=~/.kube/heap.yaml, or add it to your shell's rc file.
kubectl: command not foundThe 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.
ForbiddenYou're logged in, and nothing grants you that.
UnauthorizedThe token wasn't accepted. Delete ~/.kube/cache/oidc-login and log in again.
invalid_request or a redirect error in the browserkubelogin'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.