Cloud Native 8 min read

Mastering Kubernetes Federation: Install, Join Clusters, and Sync Resources

This guide explains the purpose of Kubernetes Federation, its benefits for multi‑cluster management, step‑by‑step installation using Helm and kubefedctl, how to join and unjoin clusters, enable resource federation, and provides a cheat sheet of common commands for reliable cross‑cluster deployments.

Efficient Ops
Efficient Ops
Efficient Ops
Mastering Kubernetes Federation: Install, Join Clusters, and Sync Resources

Background

Federation aims to manage multiple Kubernetes clusters from a single control plane, across regions, cloud providers, or on‑premise clusters.

After federation, the Federation API can uniformly manage resources such as Deployments, Services, replica counts, etc.

Benefits include simplified component management, workload distribution for reliability, cross‑cluster orchestration, easier migration, geo‑aware service discovery, and multi‑cloud or hybrid‑cloud deployments.

Installation

Helm

Install Helm according to its documentation.

Controller Plane

Deploy the controller plane with Helm (v2) using the official chart:

<code>$ helm repo add kubefed-charts https://raw.githubusercontent.com/kubernetes-sigs/kubefed/master/charts
$ helm search repo kubefed
$ helm --namespace kube-federation-system upgrade -i kubefed kubefed-charts/kubefed --version=0.6.1 --create-namespace</code>

kubefedctl

Download the binary from the GitHub releases page and install it:

<code>$ wget https://github.com/kubernetes-sigs/kubefed/releases/download/v0.6.1/kubefedctl-0.6.1-linux-amd64.tgz
$ tar -zxvf kubefedctl-0.6.1-linux-amd64.tgz
$ mv kubefedctl /usr/local/bin/</code>

Cluster Operations

Set context on the host cluster

Use

kubectl config get-contexts

and

kubectl config use-context &lt;name&gt;

to select the host cluster.

Join a member cluster

<code>$ kubefedctl join &lt;cluster-name&gt; --cluster-context &lt;member-context&gt; --host-cluster-context &lt;host-context&gt; --v=2</code>

Unjoin a cluster

<code>$ kubefedctl unjoin &lt;cluster-name&gt; --cluster-context &lt;member-context&gt; --host-cluster-context &lt;host-context&gt; --v=2</code>

Get cluster information

<code>$ kubectl -n kube-federation-system get kubefedclusters
$ kubectl -n kube-federation-system get kubefedclusters -o yaml &lt;cluster&gt;</code>

Enabling Resource Federation

Use

kubefedctl enable &lt;API‑type&gt;

to make a resource type federatable. Supported identifiers include Kind (e.g., Deployment), plural name (deployments), group‑qualified name (deployment.apps), and short alias (deploy).

After enabling, a CRD such as

federatedvirtualservices

appears in the host cluster.

Sample Workflow

Apply the demo namespace and federated namespace, then deploy sample resources:

<code>kubectl apply -f example/sample1/namespace.yaml -f example/sample1/federatednamespace.yaml
kubectl apply -R -f example/sample1</code>

If a resource type is not yet enabled, the command will fail with an “unable to recognize …” error; enable the missing type (e.g.,

ClusterRoleBinding

) and re‑apply.

Common Commands Cheat Sheet

<code>helm list --all-namespaces
helm --namespace kube-federation-system upgrade -i kubefed kubefed-charts/kubefed --version=0.6.1 --create-namespace
kubefedctl join &lt;cluster&gt; --cluster-context &lt;ctx&gt; --host-cluster-context &lt;host&gt; --v=2
kubectl config get-contexts
kubectl -n kube-federation-system get kubefedclusters
kubectl api-resources | grep kubefed
kubefedctl unjoin &lt;cluster&gt; --cluster-context &lt;ctx&gt; --host-cluster-context &lt;host&gt; --v=2
kubectl -n kube-federation-system delete FederatedTypeConfig --all
helm --namespace kube-federation-system uninstall kubefed</code>
kubernetesMulti-ClusterHelmFederationkubectlkubefed
Efficient Ops
Written by

Efficient Ops

This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.