Skip to main content

Kubernetes is a powerful orchestration tool, but managing it across multiple clusters while ensuring high availability (HA) can be challenging. Rancher, an open-source Kubernetes management platform, simplifies this process. This blog post will guide you through setting up Rancher in a high availability configuration, ensuring your Kubernetes management platform remains resilient and available.

Introduction to Rancher

Rancher provides a comprehensive suite of tools for deploying, managing, and securing Kubernetes clusters across various environments. With features like multi-cluster management, user authentication, role-based access control (RBAC), and integrated monitoring, Rancher is a robust solution for managing Kubernetes at scale.

Key Features of Rancher in HA

  1. Multi-Cluster Management: Centralized control for managing multiple Kubernetes clusters across different environments.
  2. User Authentication and RBAC: Integration with existing authentication systems and fine-grained access controls.
  3. App Catalog: Deploy applications using Helm charts from the built-in Rancher app catalog.
  4. Cluster Provisioning: Simplified cluster provisioning on various infrastructure providers.
  5. Comprehensive Monitoring: Integrated monitoring and alerting using Prometheus and Grafana.
  6. Backup and Restore: Built-in tools for cluster backup and restore.
  7. CIS Benchmarking: Automated security scanning to ensure clusters comply with industry standards.

Prerequisites

  • At least three nodes to ensure high availability.
  • A load balancer to distribute traffic across Rancher server nodes.
  • Persistent storage solution (e.g., NFS, GlusterFS) for Rancher server data.
  • Docker installed on all nodes.
  • Domain name for accessing the Rancher server (recommended).

Step-by-Step Setup Guide

Step 1: Prepare Your Environment

  1. Provision Nodes: Ensure you have at least three nodes provisioned for the Rancher server, along with a load balancer to distribute traffic.
  2. Install Docker: Install Docker on all nodes. Follow the official Docker installation guide for your operating system.
  3. Configure DNS: Set up DNS records to point to your load balancer. This will provide a single endpoint for accessing the Rancher UI.

Step 2: Install Rancher in HA Mode

  1. Create a Shared Storage: Set up a shared storage solution accessible by all Rancher server nodes.
  2. Download the Rancher HA Installer: On one of the nodes, download the Rancher HA installer.
    sh
    curl -sfL https://get.rancher.io | sh -
  3. Create a Kubernetes Cluster for Rancher: Use RKE (Rancher Kubernetes Engine) to create a Kubernetes cluster for Rancher.
    yaml
    nodes:
    - address: <node1-ip>
    user: <ssh-user>
    role: [controlplane,etcd,worker] - address: <node2-ip>
    user: <ssh-user>
    role: [controlplane,etcd,worker] - address: <node3-ip>
    user: <ssh-user>
    role: [controlplane,etcd,worker] services:
    etcd:
    snapshot: true
    creation: 6h
    retention: 24h
  4. Install RKE:
    sh
    curl -LO https://github.com/rancher/rke/releases/download/v1.3.0/rke_linux-amd64
    chmod +x rke_linux-amd64
    sudo mv rke_linux-amd64 /usr/local/bin/rke
  5. Deploy the Cluster:
    sh
    rke up --config <your-cluster-config.yaml>
  6. Install Cert-Manager: Cert-Manager manages TLS certificates for Rancher.
    sh
    kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.3.1/cert-manager.yaml
  7. Install Rancher: Add the Helm repository and install Rancher.
    sh
    helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
    kubectl create namespace cattle-system
    helm install rancher rancher-latest/rancher --namespace cattle-system --set hostname=<your-domain> --set replicas=3
  8. Verify Installation: Ensure Rancher pods are running and accessible.
    sh
    kubectl -n cattle-system get pods

Step 3: Configure Load Balancer

  1. Set Up Load Balancer: Configure your load balancer to distribute traffic across the three Rancher nodes. Ensure it uses the same DNS name you configured earlier.
  2. Health Checks: Configure health checks to ensure traffic is only directed to healthy Rancher nodes.

Step 4: Secure and Harden Rancher

  1. Enable SSL/TLS: Rancher should be accessed over HTTPS. Use Cert-Manager to manage certificates or bring your own certificates.
  2. Configure RBAC: Define user roles and permissions to control access to Rancher resources.
  3. Set Up Monitoring and Alerts: Use Rancher’s integrated Prometheus and Grafana for monitoring. Configure alerts to notify you of any issues.
  4. Regular Backups: Schedule regular backups of your Rancher configuration and Kubernetes clusters.

Conclusion

Setting up Rancher in a high availability configuration ensures your Kubernetes management platform is resilient and always available. By following the steps outlined in this guide, you can leverage Rancher’s powerful features to manage your Kubernetes clusters efficiently and securely. With Rancher, you gain a unified platform for deploying, managing, and securing Kubernetes, even in the most demanding environments.

Feel free to reach out with any questions or comments, and happy Kubernetes managing with Rancher in high availability!