curl -fsSL get.docker.com | bash
curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
In the server running the cluster get the environment variable K3S_TOKEN from container containing the word server-0
in the name.
docker ps
output
58096ee2bad0 rancher/k3s:v1.26.0-k3s2 "/bin/k3s server --t…" 6 months ago Up 6 weeks k3d-k3s-default-server-0
Now that we have the container name k3d-k3s-default-server-0
it is possible to get the token:
docker exec -it k3d-k3s-default-server-0 env | grep K3S_TOKEN
the desired output is
K3S_TOKEN=wiVEjCKZbCBxxxXXMTGf
Variables:
- CLUSTER_IP: Host IP where the cluster is available
- CLUSTER_PORT: Kubernetes API Port exposed by the server load balancer (available in ~/.kube/config )
- TOKEN: The token obtained from the server-0 container
k3d node create agent-0 --cluster https://$CLUSTER_IP:$CLUSTER_PORT --role agent --image rancher/k3s:v1.26.0-k3s2 --token $TOKEN