Rancher is an open-source container management platform that makes it easy to deploy and manage Kubernetes clusters anywhere — cloud, on-prem, or edge.
What Is Rancher?
Rancher by SUSE provides a unified management layer for multiple Kubernetes clusters. It handles provisioning, upgrades, monitoring, and access control across all your clusters from a single pane of glass.
Key Features:
- Multi-cluster management
- Built-in monitoring (Prometheus + Grafana)
- Centralized authentication and RBAC
- App catalog (Helm charts)
- Cluster provisioning on any infrastructure
- Fleet for GitOps at scale
- Backup and disaster recovery
Installation
# Install Rancher via Docker (quick start)
docker run -d --restart=unless-stopped \
-p 80:80 -p 443:443 \
--privileged \
rancher/rancher:latest
# Or via Helm on existing K8s
helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
helm install rancher rancher-stable/rancher \
--namespace cattle-system --create-namespace \
--set hostname=rancher.example.com
Rancher API: Programmatic Cluster Management
import requests
RANCHER = "https://rancher.example.com/v3"
TOKEN = "token-xxxxx:yyyyyyyyyy"
HEADERS = {"Authorization": f"Bearer {TOKEN}"}
# List all clusters
clusters = requests.get(f"{RANCHER}/clusters", headers=HEADERS, verify=False).json()
for cluster in clusters["data"]:
print(f"Cluster: {cluster['name']}, State: {cluster['state']}, Nodes: {cluster['nodeCount']}")
# Get cluster kubeconfig
kubeconfig = requests.post(
f"{RANCHER}/clusters/{cluster_id}?action=generateKubeconfig",
headers=HEADERS, verify=False
).json()
print(kubeconfig["config"])
Project and Namespace Management
# Create a project
project = requests.post(f"{RANCHER}/projects", headers=HEADERS, verify=False, json={
"name": "production-apps",
"clusterId": cluster_id,
"description": "Production application workloads"
}).json()
# Create namespace in project
namespace = requests.post(
f"{RANCHER}/clusters/{cluster_id}/namespaces",
headers=HEADERS, verify=False,
json={
"name": "my-app",
"projectId": project["id"]
}
).json()
Deploy Apps via Catalog
# List available Helm charts
catalogs = requests.get(f"{RANCHER}/catalogs", headers=HEADERS, verify=False).json()
# Install a Helm chart
requests.post(
f"{RANCHER}/clusters/{cluster_id}/apps",
headers=HEADERS, verify=False,
json={
"name": "redis",
"targetNamespace": "default",
"externalId": "catalog://?catalog=library&template=redis&version=17.0.0",
"answers": {"architecture": "standalone"}
}
)
Monitoring API
# Get cluster metrics
metrics = requests.get(
f"{RANCHER}/clusters/{cluster_id}/clusterMonitorGraphs",
headers=HEADERS, verify=False
).json()
# Get node conditions
nodes = requests.get(
f"{RANCHER}/clusters/{cluster_id}/nodes",
headers=HEADERS, verify=False
).json()
for node in nodes["data"]:
print(f"Node: {node['nodeName']}, CPU: {node['requested']['cpu']}, Memory: {node['requested']['memory']}")
Resources
- Rancher Docs
- Rancher GitHub — 23K+ stars
- API Reference
Need to scrape web data for your Kubernetes workflows? Check out my web scraping tools on Apify — production-ready actors for Reddit, Google Maps, and more. Questions? Email me at spinov001@gmail.com
Top comments (0)