# The gateway: Kubernetes clusters The gateway at [k8s.socialweb.computer](https://k8s.socialweb.computer/) runs tenant Kubernetes clusters whose nodes are VMs it requests on the market for you. ## In a browser Sign in at [k8s.socialweb.computer](https://k8s.socialweb.computer/), create a cluster, pick a lifetime (1, 8 or 24 hours, or no expiry), download its kubeconfig, revoke it. ## From the CLI With a `goat account login` session of your account: ```sh GW=https://k8s.socialweb.computer AUD=did:web:k8s.socialweb.computer N=com.publicdomainrelay.temp.cluster CL=my-cluster xrpc() { m=$2; v=$1; shift 2 goat xrpc "$v" "$GW" "$N.$m" "$@" "Authorization:Bearer $(goat account service-auth --aud "$AUD" --lxm "$N.$m")" } xrpc procedure createCluster name="$CL" until xrpc query listClusters | jq -e --arg n "$CL" '.clusters[] | select(.name==$n and .phase=="Ready")' >/dev/null; do sleep 5; done umask 077 xrpc procedure getKubeconfig name="$CL" ttlSeconds:=3600 | jq -r .kubeconfig > "$CL.kubeconfig.yaml" KUBECONFIG=./$CL.kubeconfig.yaml kubectl get ns ``` `ttlSeconds:=3600`, `28800` or `86400`; `0` never expires. Revoke the newest kubeconfig, then delete the cluster: ```sh S=$(xrpc query listKubeconfigs name=="$CL" | jq -r '[.kubeconfigs[] | select(.revoked|not)] | sort_by(.createdAt) | last | .serial') xrpc procedure revokeKubeconfig name="$CL" serial="$S" xrpc procedure deleteCluster name="$CL" ``` Deleting the cluster, `revokeIdentity` and signing out on the page revoke every kubeconfig of it too. Your own gateway in your requester's kcp, with no web app: `run requester --with-gateway` ([acceptance/0013](acceptance/0013-mixed-prod.md)); in a local market: `dev up --with-gateway` ([acceptance/0012](acceptance/0012-infra-quickstart.md)). ## Operating the gateway Prod gets a release only from CI `promote` ([deploy.md](deploy.md)), which runs `scripts/deploy.sh` on the gateway host. Its environment: | variable | meaning | default | | --- | --- | --- | | `BINARY`, `SHA256` | the release binary and its published sha256; a mismatch stops the deploy | | | `SSH_KEY`, `SSH_TARGET`, `SSH_PORT` | the deploy host | `root@socialweb.computer`, `1997` | | `ACCOUNT`, `STATE_DIR` | the gateway's account and state | `socialweb`, `/var/lib/socialweb-computer/socialweb` | | `DOMAIN`, `ORIGIN`, `KCP_ORIGIN` | the names | `socialweb.computer`, `k8s.`, `kcp.` | | `GATEWAY_ENV_FILE`, `GATEWAY_SPEC_FILE` | `gateway.env` and the `GatewaySpec` YAML | | The first run installs the gateway; every later run upgrades it and runs `install gateway` again. After a fresh install the requester account has no gateway session (`no oauth session stored`): sign it in with [oauth.md](oauth.md), `--url https://k8s.socialweb.computer/ --start-api`.