Rancher Installation for Kubernetes Management

Rancher is a comprehensive Kubernetes management platform providing centralized cluster management, workload deployment, monitoring, and administration capabilities. This guide covers Docker and Helm installation methods, importing and provisioning clusters, working with catalogs, integrated monitoring, and managing multiple Kubernetes clusters from a single pane of glass on your VPS and baremetal infrastructure.

Table of Contents

Rancher Overview

What is Rancher?

Rancher is an open-source multi-cluster Kubernetes management platform:

  • Single control pane for multiple clusters
  • Deploy applications across clusters
  • Integrated monitoring and logging
  • RBAC and multi-tenancy
  • Complete Kubernetes management UI

Architecture

Rancher Management Cluster
├── API Server
├── Database (etcd)
├── Authentication (local/external)
└── Monitoring Stack
        ↓
    Remote Clusters
    ├── User Clusters
    ├── Imported Clusters
    └── Provisioned Clusters

Key Features

  • Multi-Cluster Management: Manage unlimited clusters
  • Workload Management: Deploy apps easily via UI
  • Catalog: Pre-built application templates
  • Monitoring: Integrated Prometheus and Grafana
  • Logging: Aggregated cluster logs
  • RBAC: Global and cluster-level access control
  • Projects: Logical grouping of namespaces

Installation Methods

Docker Installation

Quick setup using Docker:

# Create directory for persistent data
mkdir -p /opt/rancher

# Run Rancher in Docker
docker run -d \
  --restart=unless-stopped \
  -p 80:80 -p 443:443 \
  -v /opt/rancher:/var/lib/rancher \
  --name rancher \
  rancher/rancher:v2.7.0

# Get bootstrap password
docker logs rancher 2>&1 | grep "Bootstrap Password:"

# Access: https://localhost

Helm Installation on Kubernetes

Install Rancher management cluster using Helm:

# Add Helm repository
helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
helm repo update

# Create namespace
kubectl create namespace cattle-system

# Create certificate issuer (using cert-manager)
kubectl apply -f - << 'EOF'
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: rancher-selfsigned
  namespace: cattle-system
spec:
  selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: tls-rancher-ingress
  namespace: cattle-system
spec:
  secretName: tls-rancher-ingress
  commonName: rancher.example.com
  issuerRef:
    name: rancher-selfsigned
    kind: Issuer
EOF

# Install Rancher
helm install rancher rancher-stable/rancher \
  --namespace cattle-system \
  --set hostname=rancher.example.com \
  --set bootstrapPassword=InitialPassword123 \
  --set ingress.tls.source=rancher \
  --set certmanager.enabled=false

# Wait for deployment
kubectl rollout status deployment/rancher -n cattle-system

Production Helm Installation

With Let's Encrypt certificates:

# Install cert-manager first
helm repo add jetstack https://charts.jetstack.io
helm repo update

helm install cert-manager jetstack/cert-manager \
  -n cert-manager \
  --create-namespace \
  --set installCRDs=true

# Install Rancher with Let's Encrypt
helm install rancher rancher-stable/rancher \
  --namespace cattle-system \
  --create-namespace \
  --set hostname=rancher.example.com \
  --set bootstrapPassword=StrongPassword123 \
  --set ingress.tls.source=letsEncrypt \
  --set [email protected] \
  --set letsEncrypt.environment=production

Verify Installation

# Check Rancher pods
kubectl get pods -n cattle-system

# Get Rancher service
kubectl get svc -n cattle-system -l app=rancher

# Access via port-forward
kubectl port-forward -n cattle-system svc/rancher 8443:443

Cluster Import and Management

Importing Existing Clusters

Import a cluster into Rancher management:

  1. In Rancher UI: Clusters → Import Existing
  2. Select cluster type (generic Kubernetes)
  3. Copy provided kubectl command
  4. Run on target cluster:
# Run provided command from Rancher UI
kubectl apply -f https://rancher.example.com/v3/import/xxxxx.yaml

Or import via kubectl directly:

# Execute on cluster to import
curl --insecure -sfL https://rancher.example.com/v3/import/xxxxx.yaml | kubectl apply -f -

# Verify agent installation
kubectl get pods -n cattle-system

Managing Imported Clusters

Once imported:

  • View cluster nodes and resources
  • Deploy applications
  • Manage workloads
  • Monitor cluster health
  • Configure networking

Cluster API Credentials

# Get cluster credentials
kubectl config view --flatten

# Export kubeconfig for imported cluster
# Via Rancher UI: Clusters → Download KubeConfig

Workload Deployment

Deploying via Rancher UI

  1. Select Cluster → Default Project
  2. Workloads → Deployments
  3. Create Deployment
  4. Configure:
    • Container image
    • Ports and environment
    • Resources and replicas
    • Storage volumes
  5. Create

Deploying via kubectl

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
  namespace: default
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web-app
  template:
    metadata:
      labels:
        app: web-app
    spec:
      containers:
      - name: web
        image: web:1.0
        ports:
        - containerPort: 8080
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 500m
            memory: 512Mi

Deploy:

kubectl apply -f deployment.yaml

Managing Services and Ingress

Create service:

# Via Rancher UI: Workloads → Services
# Or kubectl
kubectl expose deployment web-app --port=80 --target-port=8080

Create ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web-app
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
  tls:
  - hosts:
    - web.example.com
    secretName: web-tls
  rules:
  - host: web.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: web-app
            port:
              number: 80

Catalogs and Templates

Using Built-in Catalogs

Rancher includes Helm catalogs for easy deployments:

  1. Apps & Marketplace → Installed Apps
  2. Create
  3. Select app from catalog (WordPress, MySQL, etc.)
  4. Configure and deploy

Adding Custom Catalogs

Add custom Helm chart repositories:

# Via Rancher UI:
# Apps & Marketplace → Repositories
# Add Helm Repository
# Name: my-charts
# URL: https://charts.example.com

# Or via kubectl/API
kubectl apply -f - << 'EOF'
apiVersion: catalog.cattle.io/v1
kind: ClusterRepo
metadata:
  name: my-charts
spec:
  url: https://charts.example.com
  gitRepo: https://github.com/example/charts.git
  gitBranch: main
EOF

Creating Application Templates

Create reusable templates:

apiVersion: catalog.cattle.io/v1
kind: AppTemplate
metadata:
  name: my-app-template
  namespace: cattle-system
spec:
  chart:
    name: my-app
    repo: my-charts
    version: 1.0.0
  questions:
  - variable: replicas
    label: Number of Replicas
    type: integer
    default: 3
  - variable: imageTag
    label: Image Tag
    type: string
    default: latest

Monitoring Integration

Enabling Monitoring

# Via Rancher UI: Monitoring
# Or install via Helm
helm install prometheus-community/kube-prometheus-stack \
  -n monitoring \
  --create-namespace

Viewing Metrics

  1. Cluster → Monitoring
  2. Dashboard shows:
    • Cluster metrics
    • Node resources
    • Pod resource usage

Creating Custom Dashboards

In Grafana (integrated with Rancher):

  1. Dashboards → New Dashboard
  2. Add panels with Prometheus queries
  3. Visualize cluster metrics

Cluster Provisioning

Provisioning New Clusters

Create managed clusters via Rancher:

  1. Clusters → Create
  2. Select cluster type (RKE2, K3s, etc.)
  3. Configure:
    • Cluster name
    • Kubernetes version
    • Node count and specs
  4. Provision

RKE2 Cluster Provisioning

# Rancher automatically provisions via RKE2
# View cluster creation status in Rancher UI
# Logs available at: /var/lib/rancher/rke2/agent/logs/

Practical Examples

Example: Multi-Cluster Setup

#!/bin/bash

echo "=== Installing Rancher Management Cluster ==="

# Create management cluster
k3s_version="v1.27.0"
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE=644 sh -

# Install cert-manager
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.12.0/cert-manager.yaml

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

helm install rancher rancher-stable/rancher \
  -n cattle-system \
  --create-namespace \
  --set hostname=rancher.example.com \
  --set bootstrapPassword=ManagementPassword123 \
  --set ingress.tls.source=letsEncrypt \
  --set [email protected]

echo "=== Rancher Installed ==="
echo "Access at: https://rancher.example.com"

# Import existing clusters
echo "=== Ready to import clusters ==="
echo "In Rancher UI: Clusters → Import Existing"

Example: Project and RBAC Setup

---
# Project for team
apiVersion: management.cattle.io/v3
kind: Project
metadata:
  name: backend-team
spec:
  displayName: "Backend Team"
  description: "Backend service development"
---
# Cluster member role
apiVersion: management.cattle.io/v3
kind: ClusterRoleTemplateBinding
metadata:
  name: backend-team-member
spec:
  clusterName: local
  roleTemplateName: admin
  userPrincipalName: team-members-group
---
# Project namespace
apiVersion: v1
kind: Namespace
metadata:
  name: backend
  labels:
    cattle.io/project: backend-team

Conclusion

Rancher provides a comprehensive platform for managing Kubernetes across your organization. By centralizing cluster management, providing intuitive UI for workload deployment, integrating monitoring and logging, and supporting multiple clusters from a single pane of glass, Rancher dramatically simplifies Kubernetes operations. Start with importing existing clusters, progress to managing applications through the UI, and leverage catalogs for rapid deployments. Rancher's flexibility supports both small deployments on VPS and large-scale multi-cluster infrastructure on baremetal servers, making it an excellent choice for organizations of any size managing Kubernetes infrastructure.