This topic describes how to federate multiple clusters.

Prerequisites

Background information

In disaster recovery scenarios, you may deploy your workloads across multiple regions. This needs you to manage Kubernetes clusters across different regions. Kubernetes Cluster Federation (KubeFed) is a multi-cluster management project developed within the Kubernetes community. It enables managing multiple Kubernetes clusters across regions and cloud service providers. With KubeFed, you can coordinate the configurations of multiple Kubernetes clusters through a single set of APIs in a hosting cluster. For more information about KubeFed concepts, see this GitHub project.KubeFed concepts

Procedure

  1. Run the kubectl config get-contexts command to query cluster information.
    If the following information is displayed, it indicates that the configuration is complete.
    CURRENT   NAME       CLUSTER    AUTHINFO            NAMESPACE
    *         cluster1   cluster1   kubernetes-admin1
              cluster2   cluster2   kubernetes-admin2
  2. Run the following commands to set cluster1 to host cluster and set cluster2 to member cluster.
    Set the host cluster
    kubefedctl join host-cluster --cluster-context=cluster1 \
        --host-cluster-context=cluster1 --v=2
    Set the member cluster
    kubefedctl join member-cluster-1 --cluster-context=cluster2 \
        --host-cluster-context=cluster1 --v=2
  3. Run the following command to check the cluster federation.
    If the following information is displayed, it indicates that cluster federation is complete.
    kubectl get federatedcluster -n kube-federation-system
    NAMESPACE                NAME               READY   AGE
    kube-federation-system   host-cluster       True    104d
    kube-federation-system   member-cluster-1   True    104d