Cluster federation
- Docker & Kubernetes course
- Expert
- Lesson 26/47
- 4 min
Learn cluster federation approaches.
Cluster federation
Federation is distributing workloads to several clusters from a single centre: "4 replicas of this app in uretim-eu, 2 in uretim-tr". The old KubeFed project was abandoned; today this is usually done in two ways:
- GitOps: Argo CD ApplicationSet or Flux applies the same chart to each cluster with environment-specific values.
- Multi-cluster managers: Karmada, Open Cluster Management; distribution with propagation policies.
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: magaza
spec:
generators:
- list:
elements:
- cluster: uretim-eu
url: https://eu.k8s.sirket.com
- cluster: uretim-tr
url: https://tr.k8s.sirket.com
template:
metadata:
name: 'magaza-{{cluster}}'
spec:
source:
repoURL: https://github.com/ali/platform.git
path: uygulamalar/magaza
helm:
valueFiles: ['values-{{cluster}}.yaml']
destination:
server: '{{url}}'
namespace: magazaWorking with Argo CD
Argo CD compares each Application's desired state in Git with the actual state in the cluster: Synced/OutOfSync and Healthy/Degraded. Clusters are registered with Argo CD:
argocd cluster add uretim-eu
argocd app list
NAME CLUSTER STATUS HEALTH
magaza-uretim-eu https://eu.k8s.sirket.com Synced Healthy
magaza-uretim-tr https://tr.k8s.sirket.com Synced Healthy
argocd app sync magaza-uretim-trPractice Sync the applications
Write three commands: register the uretim-tr context with Argo CD; list the Argo CD applications; sync the magaza-uretim-tr application.
Starter code
# buraya yazSample solution
argocd cluster add uretim-tr
argocd app list
argocd app sync magaza-uretim-trExpected output
Cluster 'https://tr.k8s.sirket.com' added NAME CLUSTER STATUS HEALTH magaza-uretim-eu https://eu.k8s.sirket.com Synced Healthy magaza-uretim-tr https://tr.k8s.sirket.com OutOfSync Healthy Operation: Sync Phase: Succeeded
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What does the list generator in an ApplicationSet produce?
- A Helm chart
- An Argo CD Application from the template for each element Correct answer
- A Deployment
- A cluster
Explanation: The element's fields fill template variables like {{cluster}}.
2 Register a cluster with Argo CD.
argocd cluster ____ uretim-eu
argocd cluster add uretim-eu
Explanation: cluster add uses the kubeconfig context.
3 Match.
| Term | Meaning |
|---|---|
ApplicationSet |
Template for many clusters |
Synced |
Same as Git |
OutOfSync |
Different from Git |
Karmada |
Multi-cluster manager |