<p>I need some help from the community, I'm still new to K8 and Spring Boot.  Thanks all in advance.<br />
what I need is  to have 4 K8 pods running in K8 environment and each pod have slightly different configuration from each other, for example, I have a property in one of my java class called regions, it extract it's value from Application.yml, like</p>
<p><strong>@Value(&quot;${regions}&quot;)<br />
Private String regions;</strong></p>
<p>Now after deploy it to K8 env I want to have 4 pods(I can configure it in helm file) running and in each pod the <strong>regions</strong> field should have different value.
Is this something achievable ? Can anyone please give any advice ?</p>

yarkanlik
<p>If you want to run <strong>4</strong> different pods with different configurations, you have to deploy the <strong>4</strong> different deployments in <strong>kubernetes</strong>.</p>
<p>You can create the different <code>configmap</code> as per need storing the whole <code>Application.yaml</code> file or environment variables and inject it to <strong>different</strong> <strong>deployments</strong>.</p>
<p>how to store whole <code>application.yaml</code> inside <code>config map</code></p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: yaml-region-first
data:
  application.yaml: |-
    data: test,
    region: first-region
</code></pre>
<p>the same way you can create the config map with the second deployment.</p>
<pre><code> apiVersion: v1
    kind: ConfigMap
    metadata:
      name: yaml-region-second
    data:
      application.yaml: |-
        data: test,
        region: second-region
</code></pre>
<p>you can inject this <code>configmap</code> to each deployment</p>
<p>example :</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: hello-app
  name: hello-app
  namespace: default
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: hello-app
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: hello-app
    spec:
      containers:
      - name: nginx
        image: nginx
        imagePullPolicy: IfNotPresent
        volumeMounts:
          - mountPath: /etc/nginx/app.yaml
            name: yaml-file
            readOnly: true
      volumes:
      - configMap:
          name: yaml-region-second
          optional: false
        name: yaml-file
</code></pre>
<p>accordingly, you can also create the helm chart.</p>
<p>If you just to pass the single environment instead of storing the whole file inside the <code>configmap</code> you can directly add value to the deployment.</p>
<p>Example :</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: print-greeting
spec:
  containers:
  - name: env-print-demo
    image: bash
    env:
    - name: REGION
      value: &quot;one&quot;
    - name: HONORIFIC
      value: &quot;The Most Honorable&quot;
    - name: NAME
      value: &quot;Kubernetes&quot;
    command: [&quot;echo&quot;]
    args: [&quot;$(GREETING) $(HONORIFIC) $(NAME)&quot;]
</code></pre>
<p><a href="https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/</a></p>
<p>for each deployment, your environment will be different and in helm, you can <code>dynamically</code> also <code>update</code> or <code>overwrite</code> it using CLI command.</p>
