Managing Kubernetes with Rancher: The Home Lab Way

I’ve been running Kubernetes at home for years now, and I’ve tried just about every management tool out there. From kubectl and a bunch of YAML files to various dashboards and UIs, I’ve experimented with it all. But the one tool that’s been a constant in my home lab journey is Rancher - a complete container management platform that makes Kubernetes management almost… dare I say it… enjoyable?

Today, I want to walk you through setting up Rancher in your home lab and show you some of the features that have made it indispensable for me.

What is Rancher and Why Should You Care?

Rancher is an open-source platform for managing Kubernetes clusters. Think of it as mission control for all your container workloads. It gives you:

  • A unified interface for managing multiple clusters (perfect if you’re running different K8s distros)
  • Simplified deployment of applications via apps & marketplace
  • Built-in monitoring, logging, and alerting
  • User management and role-based access control
  • A clean, intuitive UI that’s actually useful (rare in the Kubernetes world!)

If you’re running even a single Kubernetes cluster at home, Rancher can save you countless hours of typing kubectl commands and editing YAML files by hand.

Setting Up Rancher in Your Home Lab

There are several ways to deploy Rancher, but I’ll focus on two approaches that work well for home labs.

Option 1: Docker Deployment (Quickstart)

The fastest way to get up and running is with Docker:

docker run -d --restart=unless-stopped \
  -p 80:80 -p 443:443 \
  --privileged \
  rancher/rancher:latest

That’s it! Navigate to https://your-server-ip and you’ll be prompted to set a password and server URL.

But while this method is quick, I prefer the next approach for a more production-like setup.

Option 2: Installing Rancher on K3s

My preferred method is to run Rancher on a lightweight Kubernetes distribution like K3s. This gives you better reliability and easier upgrades.

First, install K3s:

curl -sfL https://get.k3s.io | sh -

Next, install cert-manager (required for Rancher to manage certificates):

kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.12.2/cert-manager.yaml

Then, install Rancher using Helm:

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

kubectl create namespace cattle-system

helm install rancher rancher-stable/rancher \
  --namespace cattle-system \
  --set hostname=rancher.yourdomain.com \
  --set bootstrapPassword=admin

Depending on your home lab setup, you might want to use a load balancer or ingress controller. I use Traefik, which comes pre-installed with K3s:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: rancher
  namespace: cattle-system
spec:
  rules:
  - host: rancher.yourdomain.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: rancher
            port:
              number: 80
  tls:
  - hosts:
    - rancher.yourdomain.com
    secretName: rancher-tls

Importing Your Existing Clusters

Once Rancher is running, you can import your existing Kubernetes clusters. This is my favorite part because it doesn’t require you to rebuild anything.

  1. In the Rancher UI, go to “Cluster Management”
  2. Click “Import Existing”
  3. Choose a name for your cluster
  4. Copy the provided kubectl command and run it on your existing cluster

Rancher will install its agent on your cluster and begin managing it. Magic!

Setting Up Monitoring

Rancher makes it dead simple to deploy Prometheus and Grafana for monitoring:

  1. From your cluster’s dashboard, go to “Apps”
  2. Select “Monitoring” from the Charts
  3. Install with default settings (or customize as needed)

In minutes, you’ll have a full monitoring stack with pre-configured dashboards for nodes, pods, workloads, and more.

Here’s what my Grafana dashboard looks like for my home K8s cluster:

Rancher Grafana Dashboard

Creating Deployments Through the UI

While I’m a big fan of GitOps and declarative deployments, sometimes you just want to quickly spin up a container without writing YAML. Rancher makes this painless:

  1. Go to your cluster
  2. Select “Workload > Deployments”
  3. Click “Create”
  4. Fill in the form with your container details

You get a nice UI for setting environment variables, volumes, health checks, and more. Once you’re happy with it, Rancher generates and applies the YAML behind the scenes.

Rancher Fleet for GitOps

One of the newer features I love is Fleet, Rancher’s GitOps engine. It allows you to manage deployments across clusters using Git repositories:

# Example fleet.yaml
defaultNamespace: monitoring
helm:
  releaseName: prometheus
  repo: https://prometheus-community.github.io/helm-charts
  chart: kube-prometheus-stack
  version: 39.4.0
  values:
    grafana:
      adminPassword: ${GRAFANA_PASSWORD}
targets:
  - name: prod
    clusterSelector:
      matchLabels:
        environment: production
  - name: dev
    clusterSelector:
      matchLabels:
        environment: development
    helm:
      values:
        resources:
          limits:
            memory: 1Gi
          requests:
            memory: 512Mi

With Fleet, I maintain a Git repository with all my deployments, and Rancher automatically applies them to the appropriate clusters. When I push changes, they’re automatically deployed - proper GitOps!

Rancher for Projects and Teams

If you’re working with a team or want to compartmentalize your applications, Rancher’s projects feature is fantastic:

  1. Create different projects within a cluster (e.g., “Media,” “Home Automation,” “Development”)
  2. Assign namespaces to projects
  3. Set resource quotas for each project
  4. Create users and assign them to projects with specific permissions

This way, you can give friends or family members access to specific applications without worrying about them breaking your critical services.

Advanced: Custom Cluster Templates

As my home lab grew, I started using Rancher’s cluster templates to ensure consistency across my Kubernetes installations:

apiVersion: management.cattle.io/v3
kind: ClusterTemplate
metadata:
  name: homelab-standard
spec:
  displayName: HomeStack Standard
  revisionName: homelab-standard-v1
  members:
  - accessType: owner
    userPrincipalName: user-abc123
  template:
    spec:
      rancherKubernetesEngineConfig:
        services:
          etcd:
            backupConfig:
              enabled: true
              intervalHours: 12
              retention: 6
          kubeApi:
            auditLog:
              enabled: true
        network:
          plugin: canal
        monitoring:
          provider: metrics-server
        addons: |-
          apiVersion: v1
          kind: Namespace
          metadata:
            name: cert-manager
          ---
          apiVersion: v1
          kind: Namespace
          metadata:
            name: ingress-nginx

My Top Rancher Tips

After years of using Rancher, here are my top tips:

  1. Use the Rancher CLI: For repetitive tasks, the CLI is faster than the UI:

    rancher login https://rancher.yourdomain.com --token token-abc123
    rancher kubectl get nodes
  2. Set Up External Authentication: Connect Rancher to your identity provider (I use GitHub):

    # Sample GitHub auth config
    apiVersion: management.cattle.io/v3
    kind: AuthConfig
    metadata:
      name: github
    type: githubConfig
    properties:
      enabled: true
      clientId: your-github-client-id
      clientSecret: your-github-client-secret
      allowedPrincipals:
      - github_user://your-github-username
      - github_org://your-github-org
  3. Create Node Templates: If you’re using RKE, save node templates for quick cluster expansion.

  4. Use App Templates: Save your common applications as templates for quick deployment.

  5. Set Up Alerts: Configure alerts for node health, pod failures, and resource constraints.

Dealing with Common Rancher Issues

Even the best tools have their quirks. Here are some issues I’ve encountered and how I solved them:

Issue: Rancher UI Becomes Slow

If your Rancher UI starts lagging, check your browser’s local storage. The Rancher UI caches a lot of data, which can build up over time:

// Run this in your browser console while on the Rancher page
localStorage.clear()

Issue: Certificate Errors After DNS Changes

If you change your domain or DNS settings, Rancher certificates might need to be regenerated:

kubectl -n cattle-system delete secret tls-rancher-ingress
kubectl -n cattle-system delete secret tls-ca

Then restart the Rancher pods:

kubectl -n cattle-system rollout restart deploy/rancher

Issue: Stuck Cluster Imports

If a cluster gets stuck during import, clean up the agent resources and try again:

kubectl delete clusterrole cattle-admin cluster-owner
kubectl delete clusterrolebinding cattle-admin-binding cluster-owner
kubectl delete namespace cattle-system

The Future of Rancher

With SUSE’s acquisition of Rancher Labs, the future looks bright. The latest Rancher updates have added:

  • Better integration with cloud providers
  • Improved security features
  • Enhanced multi-cluster management
  • Lower resource requirements (great for home labs)

My wish list for future versions includes:

  • Native GitOps for everything (not just workloads)
  • Better templating for one-click deployments
  • More pre-configured monitoring dashboards

Wrapping Up

Rancher has transformed how I manage my home Kubernetes clusters. What used to be a complex, time-consuming task is now almost… fun? If you’re running Kubernetes at home and haven’t tried Rancher yet, you’re missing out on one of the best tools in the Kubernetes ecosystem.

Sure, you could manage everything with kubectl and YAML files (and I still do that sometimes), but having a well-designed UI for management, monitoring, and troubleshooting saves countless hours and reduces the learning curve for those just getting started with Kubernetes.

Are you using Rancher or another tool to manage your Kubernetes clusters? What’s been your experience? Let me know in the comments!


This post was last updated on March 5, 2024 with information about Rancher v2.7 features and Fleet GitOps capabilities.