Federation V1, the current Kubernetes federation API which reuses the Kubernetes API resources ‘as is’, is currently considered alpha for many of its features. There is no clear path to evolve the API to GA; however, there is a
Federation V2effort in progress to implement a dedicated federation API apart from the Kubernetes API. The details are available at sig-multicluster community page.
This guide explains how to use Deployments in the Federation control plane.
Deployments in the federation control plane (referred to as “Federated Deployments” in this guide) are very similar to the traditional Kubernetes Deployment and provide the same functionality. Creating them in the federation control plane ensures that the desired number of replicas exist across the registered clusters.
Some features (such as full rollout compatibility) are still in development.
This guide assumes that you have a running Kubernetes Cluster Federation installation. If not, then head over to the federation admin guide to learn how to bring up a cluster federation (or have your cluster administrator do this for you). Other tutorials, such as Kelsey Hightower’s Federated Kubernetes Tutorial, might also help you create a Federated Kubernetes cluster.
The API for Federated Deployment is compatible with the API for traditional Kubernetes Deployment. You can create a Deployment by sending a request to the federation apiserver.
You can do that using kubectl by running:
kubectl --context=federation-cluster create -f mydeployment.yaml
--context=federation-cluster flag tells kubectl to submit the
request to the Federation apiserver instead of sending it to a Kubernetes
Once a Federated Deployment is created, the federation control plane will create a Deployment in all underlying Kubernetes clusters. You can verify this by checking each of the underlying clusters, for example:
kubectl --context=gce-asia-east1a get deployment mydep
The above assumes that you have a context named ‘gce-asia-east1a’ configured in your client for your cluster in that zone.
These Deployments in underlying clusters will match the federation Deployment except in the number of replicas and revision-related annotations. Federation control plane ensures that the sum of replicas in each cluster combined matches the desired number of replicas in the Federated Deployment.
By default, replicas are spread equally in all the underlying clusters. For example:
if you have 3 registered clusters and you create a Federated Deployment with
spec.replicas = 9, then each Deployment in the 3 clusters will have
To modify the number of replicas in each cluster, you can specify
as an annotation with key
on Federated Deployment.
You can update a Federated Deployment as you would update a Kubernetes
Deployment; however, for a Federated Deployment, you must send the request to
the federation apiserver instead of sending it to a specific Kubernetes cluster.
The federation control plane ensures that whenever the Federated Deployment is
updated, it updates the corresponding Deployments in all underlying clusters to
match it. So if the rolling update strategy was chosen then the underlying
cluster will do the rolling update independently and
will apply only to individual clusters. This behavior may change in the future.
If your update includes a change in number of replicas, the federation control plane will change the number of replicas in underlying clusters to ensure that their sum remains equal to the number of desired replicas in Federated Deployment.
You can delete a Federated Deployment as you would delete a Kubernetes Deployment; however, for a Federated Deployment, you must send the request to the federation apiserver instead of sending it to a specific Kubernetes cluster.
For example, you can do that using kubectl by running:
kubectl --context=federation-cluster delete deployment mydep
Was this page helpful?
Thanks for the feedback. If you have a specific, answerable question about how to use Kubernetes, ask it on Stack Overflow. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.