Run 3 component of an app in 3 different pods

3/6/2019

I have a stateless app with 3 component say x,y,z in the same code base. Each component will be run by checking on the environment variable. I want to deploy it on Kubernetes on GCP using kind: Deployment yaml config with 3 replica pods. How can I make sure each component has a single dedicated pod to it? Can it be done on single deployment file?

-- Darshan Naik
deployment
google-cloud-platform
kubernetes
node.js

3 Answers

3/6/2019

As @Ivan Aracki mentioned in the comments, the best way would be distinguish each application component with appropriate deployment object in order to guarantee a Pod assignment here.

-- mk_sta
Source: StackOverflow

3/8/2019

As I understand your requirements stated that you have three processes application code base inside one solution. Nit sure weather three components you mentioned are independent process components or just layer front end , service , DAL etc or even tiers e.g. typical 3 tier architecture application with front end web , API and backend tier but let's call three microservices or services for simplicity...

Whichever the case is , best practices of docker , kubernetes hosted microservices pattern recommends :

  1. container per process small app (not monolethe)

  2. though there can be multiple containers per pod, suggested is keep one per pod - you can possibly have three containers inside pod

  3. You can have three pods one each for your component app provided these apps can be refactored into three separate independent processes.

  4. Having one yaml file per service and include all related objects inside seperated by --- on seperate line
  5. Three containers inside single pod or three pods per service would be easily accessible to each other

Hope this helps.

-- AnilR
Source: StackOverflow

3/6/2019

As Ivan, suggested above, deploy three deployments one each for x, y and z.

You can use the same image for the three deployments, just pass different environment variable/value for each deployment to deploy specific component. You might have to build some logic in the container start up script to retrieve the value from the environment variable and start the desired component

-- P Ekambaram
Source: StackOverflow