infra_wiki

Get cluster admin access

Get kubectl access to folly and offsite with the admin certificate from talosctl, and withdraw access.

Use this runbook to get kubectl access to the folly and offsite clusters, or to withdraw it. talosctl kubeconfig writes a kubeconfig whose one user is the cluster's admin client certificate, which is in system:masters. It comes from the admin talosconfig that Issue a talosconfig stores in 1Password.

Before you start#

  • You need kubectl, talosctl, op and the item talos-<site>-admin.

<site> is folly or offsite.

Get a kubeconfig#

  1. Add the cluster's admin context to ~/.talos/config.

    talosctl config remove <site> --noconfirm   # an old context; merge renames a duplicate
    op document get talos-<site>-admin --vault homelab --out-file /dev/shm/talos-<site>
    talosctl config merge /dev/shm/talos-<site> && rm /dev/shm/talos-<site>
  2. Write the kubeconfig for the cluster.

    talosctl --context <site> kubeconfig --merge=false ~/.kube/<site>.yaml

    Result: The file ~/.kube/<site>.yaml exists.

  3. Make sure that the certificate works.

    export KUBECONFIG=~/.kube/<site>.yaml
    kubectl get nodes

    Result: Each node shows Ready.

Run the command again to renew an expired certificate. If it fails, check the control plane.

talosctl --context <site> health

Withdraw access#

Use this procedure if you lose a workstation or a talosconfig.

warning

A lost workstation holds the admin certificates and the talosconfig. Nothing can revoke them. Only a CA rotation withdraws them, as PKI describes.

caution

On folly, a Kubernetes CA rotation strands each worker fleetd installed: Talos deletes a kubelet certificate that no accepted CA signed, and the kubelet then bootstraps with the token the Talos root gives it, which no Secret holds. A lost talosconfig alone needs only the Talos API CA, talosctl rotate-ca --kubernetes=false. After a rotation of the Kubernetes CA, do Rejoin fleetd's workers after a CA rotation.

  1. Run talosctl rotate-ca on each cluster, as PKI describes.
  2. Issue a new talosconfig, as Issue a talosconfig describes.

note

nix/system/user.nix gives the jawn user the keys of https://github.com/jonpulsifer.keys (the keys flake input). It gives the rowbutt user, the host user for Rowbutt, the keys of https://github.com/rowbutt.keys (rowbuttkeys). Both users are in wheel, and nix/profiles/fleet.nix gives wheel passwordless sudo. The Talos nodes run no SSH server; these keys reach the NixOS hosts only.

  1. Remove the lost SSH key from the GitHub account that holds it.

  2. Update the keys and rowbuttkeys flake inputs.

    nix flake update keys rowbuttkeys

    Result: • Updated input for each input whose keys changed.

  3. Merge the change through a pull request.

note

The NixOS hosts remove the key at their next auto-upgrade from main. A host that sets system.autoUpgrade.enable = false keeps the key until you deploy it.

  1. Deploy each host that sets system.autoUpgrade.enable = false, as Deploy a NixOS host describes.

If something goes wrong#

SymptomCauseAction
talosctl kubeconfig fails.The Talos API failed, or ~/.talos/config has no context <site>.Run talosctl --context <site> version, or do step 1 of Get a kubeconfig.
kubectl prints You must be logged in to the server.The admin certificate expired.Run step 2 of Get a kubeconfig again.

Edit on GitHub

↑↓ move ↵ open esc close