Home Explore Blog CI



kubernetes

3rd chunk of `content/en/blog/_posts/2016-07-00-Cross-Cluster-Services.md`
979060973c1e3969411c8393c72410a33f071090a69b491c00000001000008a0
- manages a set of DNS records in a public DNS provider (like Google Cloud DNS, or AWS Route 53), thus ensuring that clients of your federated service can seamlessly locate an appropriate healthy service endpoint at all times, even in the event of cluster, availability zone or regional outages.

Clients inside your federated Kubernetes clusters (i.e. Pods) will automatically find the local shard of the federated service in their cluster if it exists and is healthy, or the closest healthy shard in a different cluster if it does not.



Federations of Kubernetes Clusters can include clusters running in different cloud providers (e.g. GCP, AWS), and on-premise (e.g. on OpenStack). All you need to do is create your clusters in the appropriate cloud providers and/or locations, and register each cluster's API endpoint and credentials with your Federation API Server.



In our example, we have clusters created in 4 regions along with a federated control plane API deployed in one of our clusters, that we’ll be using to provision our service. See diagram below for visual representation.



 ![](https://lh6.googleusercontent.com/4_s4eMx0Dihz3RHENvFN16WnbaIyLadoQhYp3AYgSijDz5tTwmpuYXw4wufBKUTp1nM1vGyiFpIy6LRu3wJoj4_RXvXj6XqqlBzBB2FCttvLZw-RLaqIVXDjPwHtsGE_Q_920Zqy)



**Creating a Federated Service**



Let’s list out all the clusters in our federation:



```
kubectl --context=federation-cluster get clusters

NAME               STATUS    VERSION   AGE  
gce-asia-east1     Ready               1m  
gce-europe-west1   Ready               57s  
gce-us-central1    Ready               47s  
gce-us-east1       Ready               34s
 ```



Let’s create a federated service object:




```
kubectl --context=federation-cluster create -f services/nginx.yaml
 ```



The '--context=federation-cluster' flag tells kubectl to submit the request to the Federation API endpoint, with the appropriate credentials. The federated service will automatically create and maintain matching Kubernetes services in all of the clusters underlying your federation.



You can verify this by checking in each of the underlying clusters, for example:




```
kubectl --context=gce-asia-east1a get svc nginx  

Title: Creating Federated Services and Verifying Deployment
Summary
Federated Services use public DNS providers to ensure seamless client access to healthy service endpoints, even during outages. Clients in federated Kubernetes clusters automatically find local or nearby healthy service shards. Federations can span different cloud providers and on-premise environments by registering each cluster's API endpoint with the Federation API Server. The example showcases clusters in four regions with a federated control plane API. The process of creating a federated service involves listing clusters in the federation and creating a federated service object using kubectl, which submits the request to the Federation API endpoint. The system automatically creates and maintains matching Kubernetes services in all underlying clusters, verifiable by checking individual clusters.