Is a Kubernetes service cluster specific or can a service span across clusters?

12/22/2019

I am new to K8S. My understanding is that I will have to create a separate cluster for separate region. Say for example, I will have to create 3 clusters, one for us-south, another for eu-gb and third one for au-syd region. Now say I need my application running in each of these clusters in each region. Also, I might want this application foo to be replicated on multiple pods across multiple nodes in each region. In that case a service foo-service which will abstract this application, will it be a service specific to the regional cluster or will it span across all 3 of my clusters?

-- adi
kubernetes
kubernetes-cluster
kubernetes-pod
kubernetes-service

2 Answers

12/24/2019

My understanding is that I will have to create a separate cluster for separate region.

Yes, this is correct. You have a separate cluster for each region.

Now say I need my application running in each of these clusters in each region.

The clusters are independent, so you deploy each application in each cluster, unless you setup some Cluster Federation.

Also, I might want this application foo to be replicated on multiple pods across multiple nodes in each region.

The clusters are independent. So the application is deployed in each, and replicated within the cluster - possibly automatically with Horizontal Autoscaling, e.g. if there is more load in one region, that cluster scales up the app from 3 instances to 5 automatically and independent.

In that case a service foo-service which will abstract this application, will it be a service specific to the regional cluster or will it span across all 3 of my clusters?

The clusters are independent, so each service will also be independent of the services in the other regions. If you use Availability Zones, you can setup a cluster spanning the Availability Zones in the same Region.

-- Jonas
Source: StackOverflow

12/30/2019

In addition to explanation given by Jonas, there is a possibility to have single cluster that covers multiple zones (though with some overhead and config complication) with the Pod Topology Spread Constraints feature.

So your cluster will look like:

+---------------+---------------+---------------+
|     zoneA     |     zoneB     |     zoneC     |
+-------+-------+-------+-------+-------+-------+
| node1 | node2 | node3 | node4 | node5 | node6 |
+-------+-------+-------+-------+-------+-------+

Combined with PodAffinity/PodAntiAffinity you can try to pack any number of Pods into qualifying topology domain(s).

Needles to say that you'll have to have 3x set of services (one for each zone). You can use LoadBalancer service type for example.

As a result you'll be able to serve requests from foobar.us-south , foobar.au-sy and foobar.eu-gb separately) and spawn additional pods in particular region if needed.

Hope that (combined with the answer by Jonas) covers the topic :)

-- Nick
Source: StackOverflow