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?
Asked
Active
Viewed 490 times
0

Rohit Singh
- 169
- 2
- 2
- 9
1 Answers
0
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.

kus
- 446
- 3
- 7