Master Multi-Cluster Kubernetes with Kubefed: Cross-Cloud Scheduling & Failover
This guide walks you through deploying Kubernetes Federation (Kubefed) to manage multiple clusters across clouds, covering environment setup, control‑plane installation, cluster registration, federated resource configuration, intelligent scheduling, high‑availability, security hardening, monitoring, backup, and troubleshooting.
Overview
Kubernetes Federation (Kubefed) provides a native solution for managing multiple Kubernetes clusters as a single logical entity, enabling unified resource management, cross‑region application deployment, and automated failover for multi‑cloud or hybrid‑cloud strategies.
Key Technical Features
Unified Management UI : Single control plane to manage all clusters via a consistent API and CLI.
Intelligent Resource Scheduling : Supports multi‑dimensional policies based on region, capacity, and latency.
High‑Availability Failover : Automatic health checks and workload migration on cluster failure.
Cross‑Cloud Resource Orchestration : Abstracts differences between AWS, Azure, GCP, Alibaba Cloud, etc.
Progressive Rollout : Supports canary and blue‑green deployments across clusters.
Fine‑Grained RBAC : Role‑based access control across clusters for multi‑tenant isolation.
Typical Use Cases
Multi‑cloud active‑active architectures to avoid vendor lock‑in.
Cross‑region disaster recovery for finance, e‑commerce, and other high‑availability workloads.
Edge computing with hundreds of small clusters managed centrally.
Isolated environments for development, testing, pre‑release, and production.
Compliance‑driven data residency requirements.
Environment Requirements
Linux OS: CentOS 7+, Ubuntu 20.04+, Debian 10+
Kubernetes version: 1.23+ (both host and member clusters)
Kubefed version: v0.10.0+
kubectl version: 1.23+ (must match cluster version)
Helm 3.8+ (for installing Kubefed)
Network connectivity between clusters (VPN, dedicated line, or public internet)
Step‑by‑Step Implementation
1. Preparation
System Check
# Check OS version
cat /etc/os-release
# Verify each cluster
kubectl cluster-info
kubectl get nodes
kubectl version --short
# Check resource status
free -h
df -h
# Verify inter‑cluster network
curl -k https://cluster1.example.com:6443/healthz
curl -k https://cluster2.example.com:6443/healthzInstall Dependencies
# Install kubectl if missing
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version --client
# Install Helm 3
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
helm version
# Install kubefedctl CLI
wget https://github.com/kubernetes-sigs/kubefed/releases/download/v0.10.0/kubefedctl-0.10.0-linux-amd64.tgz
tar -zxvf kubefedctl-0.10.0-linux-amd64.tgz
sudo mv kubefedctl /usr/local/bin/
kubefedctl version
# Verify installations
which kubectl kubefedctl helmPrepare kubeconfig Files
# Create working directory
mkdir -p ~/kubefed-demo/kubeconfigs
cd ~/kubefed-demo
# Copy kubeconfig of each cluster
cp ~/.kube/config-host kubeconfigs/host-cluster.yaml
cp ~/.kube/config-cluster1 kubeconfigs/cluster1.yaml
cp ~/.kube/config-cluster2 kubeconfigs/cluster2.yaml
# Set host cluster context
export KUBECONFIG=~/kubefed-demo/kubeconfigs/host-cluster.yaml
kubectl config current-context
kubectl get nodes2. Core Configuration
Deploy Kubefed Control Plane
# Create namespace for Kubefed on host cluster
kubectl create namespace kube-federation-system
# Add Helm repo and install Kubefed chart
helm repo add kubefed-charts https://raw.githubusercontent.com/kubernetes-sigs/kubefed/master/charts
helm repo update
helm install kubefed kubefed-charts/kubefed \
--namespace kube-federation-system \
--set controllermanager.replicaCount=2 \
--set controllermanager.resources.requests.cpu=200m \
--set controllermanager.resources.requests.memory=256Mi \
--set controllermanager.resources.limits.cpu=500m \
--set controllermanager.resources.limits.memory=512Mi
# Verify components
kubectl get pods -n kube-federation-system
kubectl get deployment -n kube-federation-system
kubectl get crd | grep kubefedNote : Deploy the control plane on a dedicated host cluster and allocate at least two replicas for HA.
Register Member Clusters
# Register host cluster itself
kubefedctl join host-cluster \
--cluster-context host-cluster \
--host-cluster-context host-cluster \
--kubefed-namespace kube-federation-system \
--v=2
# Register cluster1
kubefedctl join cluster1 \
--cluster-context cluster1 \
--host-cluster-context host-cluster \
--kubefed-namespace kube-federation-system \
--kubeconfig ~/kubefed-demo/kubeconfigs/cluster1.yaml \
--v=2
# Register cluster2
kubefedctl join cluster2 \
--cluster-context cluster2 \
--host-cluster-context host-cluster \
--kubefed-namespace kube-federation-system \
--kubeconfig ~/kubefed-demo/kubeconfigs/cluster2.yaml \
--v=2
# Verify registration
kubectl get kubefedclusters -n kube-federation-system
kubectl describe kubefedcluster cluster1 -n kube-federation-system
# Check health status
kubectl get kubefedclusters -n kube-federation-system -o jsonpath='{range .items[*]}{.metadata.name}{MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
