Home Explore Blog CI



kubernetes

5th chunk of `content/en/blog/_posts/2016-12-00-Cluster-Federation-In-Kubernetes-1-5.md`
575be62361c63556e15245114d5948381df443da48194ec10000000100000bc4
**Using Federation To Run An Application**  

In our [repository](https://github.com/ContainerSolutions/k8shserver) you will find instructions on how to build a docker image with a web service that displays the container’s hostname and the Google Cloud Platform (GCP) zone.


An example output might look like this:


```
{"hostname":"k8shserver-6we2u","zone":"europe-west1-b"}
 ```


Now we will deploy the Replica Set ([k8shserver.yaml](https://github.com/ContainerSolutions/k8shserver/blob/master/rs/k8shserver.yaml)):  

```
$ kubectl --context=federation create -f rs/k8shserver
 ```



And a Federated Service ([k8shserver.yaml](https://github.com/ContainerSolutions/k8shserver/blob/master/services/k8shserver.yaml)):  

```
$ kubectl --context=federation create -f service/k8shserver
 ```



As you can see, the two commands refer to the “federation” context, i.e. to the federation control plane. After a few minutes, you will realize that underlying clusters run the Replica Set and the Service.  


**Creating The Ingress**  

After the Service is ready, we can create [Ingress](/docs/user-guide/ingress/) - the global load balancer. The command is like this:



```
kubectl --context=federation create -f ingress/k8shserver.yaml
 ```



The contents of the file point to the service we created in the previous step:



```
apiVersion: extensions/v1beta1

kind: Ingress

metadata:

  name: k8shserver

spec:

  backend:

    serviceName: k8shserver

    servicePort: 80
 ```




After a few minutes, we should get a global IP address:

```
$ kubectl --context=federation get ingress

NAME         HOSTS     ADDRESS          PORTS     AGE

k8shserver   \*         130.211.40.125   80        20m
 ```

Effectively, the response of:  



```
$ curl 130.211.40.125
 ```


depends on the location of client. Something like this would be expected in the US:



```
{"hostname":"k8shserver-w56n4","zone":"us-east1-b"}
 ```


Whereas in Europe, we might have:



```
{"hostname":"k8shserver-z31p1","zone":"eu-west1-b"}
 ```




Please refer to this [issue](https://github.com/kubernetes/kubernetes/issues/39087) for additional details on how everything we've described works.



**Demo**  




**Summary**



Cluster Federation is actively being worked on and is still not fully General Available. Some APIs are in beta and others are in alpha. Some features are missing, for instance cross-cloud load balancing is not supported (federated ingress currently only works on Google Cloud Platform as it depends on GCP [HTTP(S) Load Balancing](https://cloud.google.com/compute/docs/load-balancing/http/)).



Nevertheless, as the functionality matures, it will become an enabler for all companies that aim at global markets, but currently cannot afford sophisticated administration techniques as used by the likes of Netflix or Amazon. That’s why we closely watch the technology, hoping that it soon fulfills its promise.



PS. When done, remember to destroy your clusters:




```
$ . 5-destroy.sh
 ```


Title: Creating an Ingress and Demo of the Federated Application
Summary
After deploying the Replica Set and Federated Service, this section guides you through creating an Ingress (global load balancer) to expose the service. It describes the Ingress configuration file and how to retrieve the global IP address. The expected behavior is that requests to the IP address will be routed to instances of the service running in the closest geographical location. The section concludes with a brief summary of Cluster Federation, its current limitations, and its potential for companies aiming at global markets and reminds the user to destroy the clusters after finishing.