Now that we have the building blocks of federation conceptualized in our mind, let's review one more facet of this before setting up federation. How exactly does a common service, deployed across multiple clusters, work?
Federated services are created in a very similar fashion to regular services: first, by sending the desired state and properties of the service to an API endpoint, which is then brought to bear by the Kubernetes architecture. There are two main differences:
- A non-federated service will make an API call directly to a cluster API endpoint
- A federated service will make the call to the Federated API endpoint at federation/v1beta1, which will then redirect the API call to all of the individual clusters within the federation control plane
This second type of service allows us to extend such things as DNS service discovery across cluster boundaries. The DNS resolv chain is able to leverage service federation and public DNS records to resolve names across multiple clusters.
When a service is created, federation takes care of several things. First, it creates matching services in all clusters where kubefed specifies they reside. The health of those services is monitored so that traffic can be routed or re-routed to them. Lastly, federation ensure that there's a definitive set of public DNS records available through providers such as Route 53 or Google Cloud DNS.
Microservices residing on different pods within your Kubernetes clusters will use all of this machinery in order to locate the federated service either within their own cluster or navigate to the nearest healthy example within your federation map.