Kubernetes: single POD with many container, or many Pod with single container

3/31/2017

I've rather a teoretical question which I can't answer with the reousrces found online. The question is: what's the rule to decide how to compose containers in POD? . Let me explain with an example.

I've these microservices:

  • Authentication
  • Authorization
  • Serving content
  • (plus) OpenResty to forward the calls form one to the other and orhcestarate the flow. (is there a possibility to do so natively in K8?, it seems to have services base on nginx+lua, but not sure how it works)

For the sake of the example I avoid Databases and co, I assume they are external and not managed by kubernetes

Now, what's the correct way here LEFT or RIGHT of the image? enter image description here

LEFT : this seems easier to make it working, everything works on "localhost" , the downside is that it looses a bit the benefit of the microservices. For example, if the auth become slows and it would need more instances, I've to duplicate the whole pod and not just that service.

RIGHT seems a bit more complex, need services to expose each POD to the other PODs. Yet, here, I could duplicate auth as I need without duplicating the other containers. On the other hand I'll have a lot of pods since each pod is basically a container.

-- EsseTi
kubernetes
microservices

4 Answers

3/31/2017

Right image is better option. Easier management, upgrades, scaling.

-- Alen Komljen
Source: StackOverflow

4/1/2017

Should choose the right side of the structure, on the grounds that the deployment of the left side of the architecture model is tight coupling is not conducive to a module according to the actual needs of the business expansion capacity.

-- Ted Zhang
Source: StackOverflow

4/2/2017

It is generally recommended to keep different services in different pods or better deployments that will scale independently. The reasons are what is generally discussed as benefits of a microservices architecture.

  • A more loose coupling allowing the different services to be developed independently in their own languages/technologies,

  • be deployed and updated independently and

  • also to scale independently.

The exception are what is considered a "helper application" to assist a "primary application". Examples given in the k8s docs are data pullers, data pushers and proxies. In those cases a share file system or exchange via loopback network interface can help with critical performance use cases. A data puller can be a side-car container for an nginx container pulling a website to serve from a GIT repository for example.

-- Oswin Noetzelmann
Source: StackOverflow

3/31/2017

right image, each in own pod. multi containers in a pod should really only be used when they are highly coupled or needed for support of the main container such as a data loader.

With separate pods, it allows for each service to be updated and deployed independently. It also allows for more efficient scaling. in the future, you may need 2 or 3 content pods but still only one authorization. if they are all together you scale them all since you don't have a choice with them all together in the same pod.

-- JamStar
Source: StackOverflow