Cross-cluster service
- Docker & Kubernetes course
- Expert
- Lesson 28/47
- 4 min
Learn cross-cluster service access.
Cross-cluster service
Solutions for reaching a service in one cluster by name from another cluster:
- The Multi-Cluster Services API (MCS): a service exposed with
ServiceExportappears in other clusters under the namename.namespace.svc.clusterset.local(supported by GKE, Submariner, Cilium ClusterMesh). - Service mesh: Istio in a multi-cluster setup extends service discovery and mTLS across clusters.
- The simple way: exposing the service with an internal load balancer (LoadBalancer + DNS).
apiVersion: multicluster.x-k8s.io/v1alpha1
kind: ServiceExport
metadata:
name: odeme
namespace: magaza
# from another cluster: http://odeme.magaza.svc.clusterset.localNetwork prerequisites
For communication between clusters, the pod or service networks must not overlap and must be routable to each other. That's why CIDR ranges are planned when clusters are set up:
uretim-eu pod CIDR 10.10.0.0/16 service CIDR 10.110.0.0/16
uretim-tr pod CIDR 10.20.0.0/16 service CIDR 10.120.0.0/16
# no overlap: routing and MCS are possibleOverlapping ranges can't be changed later; the cluster may have to be rebuilt.
Practice Export the service
Write a ServiceExport YAML: multicluster.x-k8s.io/v1alpha1; name odeme, namespace magaza. Then, on a separate line, write the command listing the ServiceImports in magaza in the uretim-tr context (kubectl get serviceimports).
Starter code
# buraya yazSample solution
apiVersion: multicluster.x-k8s.io/v1alpha1
kind: ServiceExport
metadata:
name: odeme
namespace: magaza
kubectl get serviceimports -n magaza --context uretim-trExpected output
serviceexport.multicluster.x-k8s.io/odeme created NAME TYPE IP AGE odeme ClusterSetIP ["10.120.4.17"] 30s
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 In the MCS API, what is the DNS suffix of an exported service in other clusters?
- svc.cluster.local
- global.local
- mesh.local
- svc.clusterset.local Correct answer
Explanation: cluster.local is for the local cluster.
2 Expose the service to other clusters.
apiVersion: multicluster.x-k8s.io/v1alpha1
kind: ____
metadata:
name: odeme
apiVersion: multicluster.x-k8s.io/v1alpha1
kind: ServiceExport
metadata:
name: odeme
Explanation: ServiceExport exposes it; a ServiceImport appears on the other side.
3 Match.
| Term | Meaning |
|---|---|
ServiceExport |
Expose |
ServiceImport |
Visible in the other cluster |
clusterset.local |
Cluster-set DNS |
CIDR plan |
Prevents overlap |