<p>Any help much appreciated , I have couple of spring boot application running in aks with default profile , i am trying to change the profile from my deployment.yaml using helm</p>
<pre><code>
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include &quot;helm-chart.fullname&quot; . }}
  labels:
    app.kubernetes.io/name: {{ include &quot;helm-chart.name&quot; . }}
    helm.sh/chart: {{ include &quot;helm-chart.chart&quot; . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include &quot;helm-chart.name&quot; . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ include &quot;helm-chart.name&quot; . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: &quot;{{ .Values.image.repository }}:{{ .Values.image.tag }}&quot;
          imagePullPolicy: {{ .Values.image.pullPolicy }}
             
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
          env:
          - name: SPRING_PROFILES_ACTIVE
            value: &quot;dev&quot;
</code></pre>
<p>what i end up is my pod is been put to crashloopbackoff state saying</p>
<p>Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.</p>
<p>2022-01-12 12:42:49.054 ERROR 1 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :</p>
<hr />
<p>APPLICATION FAILED TO START</p>
<hr />
<p>Description:</p>
<p>The Tomcat connector configured to listen on port 8207 failed to start. The port may already be in use or the connector may be misconfigured.</p>
<p>I tried to delete the existing pod and service for the application and did a fresh deploy i still get the same error ..</p>
<p>methods tried :(in all methods docker file is created , pod is created , application in pod is setup to dev profile but the thing is it not able to start the application with the above error , when i remove the profile setting , every thing is workly perfectly fine expect the fact is the application is set to default profile)</p>
<ol>
<li>in docker file :</li>
</ol>
<p>option a. CMD [&quot;java&quot;,&quot;-jar&quot;,&quot;/app.jar&quot;, &quot;--spring.profiles.active=dev&quot;]
option b. CMD [&quot;java&quot;,&quot;-jar&quot;,&quot;-Dspring.profiles.active=dev&quot;,&quot;/app.jar&quot;]</p>
<ol start="2">
<li>changed in deployment.yml as mentioned above</li>
</ol>
<p>ps : i dont have property file in my application on src/main/resources , i have only application-(env).yml files there .</p>
<p>The idea is to set the profile first and based on the profile the application_(env).yml has to be selected</p>
<p>output from helm</p>
<pre><code>
Release &quot;app&quot; has been upgraded. Happy Helming!
NAME: email-service
LAST DEPLOYED: Thu Jan 13 16:09:46 2022
NAMESPACE: default
STATUS: deployed
REVISION: 19
TEST SUITE: None
USER-SUPPLIED VALUES:
image:
  repository: 957123096554.dkr.ecr.eu-central-1.amazonaws.com/app
service:
  targetPort: 8207

COMPUTED VALUES:
image:
  pullPolicy: Always
  repository: 957123096554.dkr.ecr.eu-central-1.amazonaws.com/app-service
  tag: latest
replicaCount: 1
service:
  port: 80
  targetPort: 8207
  type: ClusterIP


</code></pre>
<p>Any help is appreciated , thanks</p>

Dilu
<p>First of all, please check what profile the application is using, search for line like this (in log):</p>
<pre class="lang-none prettyprint-override"><code>The following profiles are active: test
</code></pre>
<p>When I tested with Spring Boot v2.2.2.RELEASE, <code>application_test.yml</code> file is not used, it has to be renamed to <code>application-test.yml</code>, for a better highlighting of a difference:</p>
<pre><code>application_test.yml # NOT working
application-test.yml # working as expected
</code></pre>
<p>What I like even more (but it is Spring Boot specific), you can use application.yml like this:</p>
<pre class="lang-yaml prettyprint-override"><code>foo: 'foo default'
bar: 'bar default'

---
spring:
  profiles:
  - test
bar: 'bar test2'
</code></pre>
<p>Why I prefer this? Because you can use multiple profiles then, e.g. <code>profile1,profile2</code> and it behaves as last wins, I mean it will override the values from <code>profile1</code> with values from <code>profile2</code>, as it was defined in this order... The same does not work with application-profileName.yml approach.</p>
