Installing Rancher

Rancher is an application that runs inside a Docker container. You can deploy this container either on one of your Kubernetes nodes or on a separate host machine. The key requirement is that all Kubernetes nodes must be able to communicate with the machine running the Rancher container, and vice versa. For more details, refer to the official Rancher documentation.

To install Rancher:

  1. On a machine with a Debian-based Linux distribution such as Ubuntu, install a Docker container.

    1. Install Docker with:

      sudo apt update sudo apt install -y docker.io
    2. Enable and start the Docker service so that it runs in the background and starts automatically after a restart:

      sudo systemctl enable --now docker
    3. To allow your current user to run Docker commands without sudo, add the user to the docker group and refresh the session:

      sudo usermod -aG docker $USER newgrp docker
  2. In Docker, create a directory for Rancher’s data and start the container:

    sudo mkdir -p /opt/rancher sudo docker run -d --restart=unless-stopped --privileged -p 8080:80 -p 8443:443 -v /opt/rancher:/var/lib/rancher --name rancher rancher/rancher:stable
  3. Increase the system’s inotify watch limits to prevent issues when running Rancher and Kubernetes on the same node:

    echo "fs.inotify.max_user_instances=512" | sudo tee -a /etc/sysctl.d/99-kubernetes-inotify.conf echo "fs.inotify.max_user_watches=524288" | sudo tee -a /etc/sysctl.d/99-kubernetes-inotify.conf sudo sysctl --system
  4. Retrieve the Bootstrap Password from the logs of the Rancher container.

    When Rancher starts for the first time, it creates a bootstrap admin account (username: admin) and generates a random default password. To extract the bootstrap password from the logs, run:

    docker logs rancher 2>&1 | grep "Bootstrap Password:"
  5. Access the Rancher user interface.

    1. Wait until Rancher fully initializes, which may take a few minutes

    2. Open a web browser and navigate to https://"<rancher_server_address>":8443 . Replace <rancher_server_address> with either the IP address or hostname of the machine where Rancher is running.

    3. Log in with admin as the username and the bootstrap password retrieved from the container logs in step 4. Follow the prompts to set a new password and complete the initial setup.

What's Next?

Installing the K3s Cluster on Premises Using Rancher