Skip to content

Instantly share code, notes, and snippets.

@Piotr1215
Last active June 4, 2021 12:05
Show Gist options
  • Save Piotr1215/8740240399890be7547566884906cf04 to your computer and use it in GitHub Desktop.
Save Piotr1215/8740240399890be7547566884906cf04 to your computer and use it in GitHub Desktop.
# Create server and agent machines
multipass launch --name k3s-server --cpus 1 --mem 1024M --disk 10G
multipass launch --name k3s-agent --cpus 1 --mem 1024M --disk 15G
# Install k3s on the server vm
multipass exec k3s-server -- /bin/bash -c "curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" sh -"
# Obtain token form the server
K3S_TOKEN=$(multipass exec k3s-server -- /bin/bash -c "sudo cat /var/lib/rancher/k3s/server/node-token")
echo $K3S_TOKEN
# Capture server IP in a variable
K3S_NODEIP_SERVER=$(multipass info k3s-server | grep IPv4 | cut -c17-29)
echo $K3S_NODEIP_SERVER
# Add agent to the cluster
multipass exec k3s-agent -- /bin/bash -c "sudo curl -sfL https://get.k3s.io | K3S_TOKEN=${K3S_TOKEN} K3S_URL=https://${K3S_NODEIP_SERVER}:6443 sh -"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment