<p>I have created the 2 config map named personservice and personservice-dev.</p>

<p>I am running spring boot application with profile dev but it is not loading the right config map. This is what I see in logs of the pod which gets crashed.</p>

<pre><code> 2019-11-05 16:29:37.336  INFO [personservice,,,] 7 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='composite-configmap', propertySources=[ConfigMapPropertySource {name='configmap.personservice.default'}]}
2019-11-05 16:29:37.341  INFO [personservice,,,] 7 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: SecretsPropertySource {name='secrets.personservice.default'}
2019-11-05 16:29:37.445  INFO [personservice,,,] 7 --- [           main] c.person.PersonMicroServiceApplication   : The following profiles are active: kubernetes,dev
</code></pre>

<p><strong>Kubectl get configmaps</strong></p>

<p><a href="https://i.stack.imgur.com/BioKS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BioKS.png" alt="enter image description here"></a></p>

<p><strong>Deployment file:</strong></p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: personservice
  labels:
    app: personservice
spec:
  replicas: 1
  selector:
    matchLabels:
      app: personservice
  template:
    metadata:
      labels:
        app: personservice
    spec:
      containers:
      - name: personservice
        image: microservice-k8s/personmicroservice-k8s:1.0
        ports:
        - containerPort: 8080
        env:
        - name: PROFILE
          value: "dev" 
        - name: SERVER_PORT
          value: "8080"
        - name: ZIPKIN_URI
          value: "http://172.19.27.145:9411"
</code></pre>

<p><strong>Bootstrap:</strong></p>

<pre><code>spring:
  application:
    name: personservice
</code></pre>

<p>You confused things. Your configmap is named <code>personservice-dev</code> and your application's name is <code>personservice</code> not <code>personservice-dev</code>, by default Spring Cloud K8S looks for configmap with name equals to <code>spring.application.name</code> and not <code>spring.application.name-{profile}</code>.</p>

<p>You have 2 ways to solve your problem:</p>

<p>1-Remove <code>personservice-dev</code> and in your <code>personservice</code> configmap:</p>

<pre><code>kind: ConfigMap
apiVersion: v1
metadata:
  name: personservice
data:
  application.yml: |-
    p1:
      pa: blabla
    ---
    spring:
      profiles: dev
    p1:
      pa: blibli
    ---
    spring:
      profiles: prod
    p1:
      pa: blublu
</code></pre>

<p>2-Keep <code>personservice-dev</code> and <code>personservice</code> and define this in <code>bootstrap.yml</code>:</p>

<pre><code>spring:
  cloud:
    kubernetes:
      config:
        name: ${spring.application.name} #This is optional
        sources:
          - name: ${spring.application.name}-${PROFILE} # Here you get your `personservice-dev` configmap
</code></pre>
