Post

Deploying Rancher to Manage K3S

What is Rancher?

Rancher is a powerful web UI that simplifies managing your Kubernetes cluster. While alternatives like Portainer exist, Rancher is preferred for this tutorial because it works seamlessly with tools like Longhorn.


Step 1: Install Helm

We will use Helm to install Rancher. Follow the official Helm installation guide. Run the following commands on your admin VM:

1
2
3
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

Verify Helm Installation To ensure Helm is installed correctly, run:

1
helm version

Step 2: Install Rancher

I will follow this Rancher installation guide Add the stable Rancher chart repository using Helm:

1
helm repo add rancher-stable https://releases.rancher.com/server-charts/stable

Create a Namespace for Rancher

1
kubectl create namespace cattle-system

Step 3: Install Cert-Manager

Cert-Manager is required to handle certificates for Rancher. We’ll install version 1.15.2.

Apply the Cert-Manager CRDs

1
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.15.2/cert-manager.crds.yaml

Add the Jetstack Helm Repository Add the repository and update it:

1
helm repo add jetstack https://charts.jetstack.io
1
helm repo update

Install Cert-Manager

1
2
3
4
helm install cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --create-namespace \
  --version v1.15.2

Verify the Cert-Manager Installation

1
kubectl get pods --namespace cert-manager

Step 4: Install Rancher

Install Rancher Using Helm Replace with the version you want to install (e.g., stable). For this tutorial, we'll use the stable version:

1
2
3
4
helm install rancher rancher-<CHART_REPO>/rancher \
  --namespace cattle-system \
  --set hostname=rancher.my.org \
  --set bootstrapPassword=admin

Check Deployment Status To verify the Rancher deployment, run:

1
kubectl -n cattle-system rollout status deploy/rancher

Confirm Installation Ensure the deployment is complete:

1
kubectl -n cattle-system get deploy rancher

Step 5: Expose the Rancher Web UI

Expose Rancher Using a LoadBalancer

1
kubectl expose deployment rancher --name=rancher-lb --port=443 --type=LoadBalancer -n cattle-system

Check the External IP Run the following command to find the external IP for the Rancher UI:

1
kubectl get svc -n cattle-system

Access Rancher Open your browser and go to the external IP address provided in the previous step. Use the credentials you specified during installation (default bootstrap password is admin) to log in.

Congratulations! 🎉 You’ve successfully deployed Rancher to manage your K3S cluster.

What’s Next

In the next blog post in my Kubernetes series, I’ll cover deploying Longhorn on K3S. Longhorn is a lightweight, reliable, and easy-to-use distributed block storage system for Kubernetes, making it an excellent addition to your Rancher-managed K3S cluster.

Stay tuned!

This post is licensed under CC BY 4.0 by the author.