How can I deploy a kubernetes replica pods with different spring profiles

695 views Asked by At

I have spring boot application and deployed in kubernetes with 4 replica pods configurations. Now I have spring profiles: api and scheduler. When api spring profile is active then only pods will run those apis and when scheduler profile is active the pods will run the scheduler code. Now I want 2 of my pods to run with api and other 2 pods with scheduler spring profile. How can I achieve that in kubernetes?

1

There are 1 answers

0
kus On

One of the option is to define two pod yaml and override the docker file CMD and entrypoint. Yaml file 'command and args' will override whatever mention in docker's Entrypoint.

For api container

  spec:
  containers:
   - name: api-container
     image: nameOfImage
     command: ["java"]
     args: ["-jar", "application.jar", "--spring.profiles.active=api"]

Similarly you can define for scheduler container.