Skip to main content
Version: Latest

2. Install Kubernetes

Once the infrastructure is ready, you can continue with setting up a Kubernetes cluster to install Rancher in.

The steps to set up RKE, RKE2, or K3s are shown below.

For convenience, export the IP address and port of your proxy into an environment variable and set up the HTTP_PROXY variables for your current shell on every node:

export proxy_host=""
export HTTP_PROXY=http://${proxy_host}
export HTTPS_PROXY=http://${proxy_host}
export NO_PROXY=,,cattle-system.svc,,

First configure the HTTP proxy settings on the K3s systemd service, so that K3s's containerd can pull images through the proxy:

cat <<'EOF' | sudo tee /etc/default/k3s > /dev/null

Rancher needs to be installed on a supported Kubernetes version. To find out which versions of Kubernetes are supported for your Rancher version, refer to the Rancher Support Matrix.

To specify the K3s (Kubernetes) version, use the INSTALL_K3S_VERSION (e.g., INSTALL_K3S_VERSION="v1.24.10+k3s1") environment variable when running the K3s installation script.

On the first node, create a new cluster:

curl -sfL | INSTALL_K3S_VERSION=<VERSION> K3S_TOKEN=<TOKEN> sh -s - server --cluster-init

And then join the other nodes:

curl -sfL | INSTALL_K3S_VERSION=<VERSION> K3S_TOKEN=<TOKEN> sh -s - server --server https://<SERVER>:6443

Where <SERVER> is the IP or valid DNS of the server and <TOKEN> is the node-token from the server found at /var/lib/rancher/k3s/server/node-token.

For more information on installing K3s see the K3s installation docs.

To have a look at your cluster run:

kubectl cluster-info
kubectl get pods --all-namespaces

Issues or errors?

See the Troubleshooting page.

Next: Install Rancher