<p>I have one spring boot microservice running on docker container, below is the Dockerfile</p>

<pre><code>FROM java:8-jre
MAINTAINER &lt;&gt;
WORKDIR deploy/
#COPY config/* /deploy/config/
COPY ./ms.console.jar /deploy/
CMD chmod +R 777 ./ms.console.jar
CMD ["java","-jar","/deploy/ms.console.jar","console"]
EXPOSE 8384
</code></pre>

<p>here my configuration stores in external folder, i.e <code>/config/console-server.yml</code> and when I started the application, internally it will load the config (spring boot functionality).</p>

<p>Now I want to separate this configuration using configmap, for that I simply created one configmap and storing all the configuration details.</p>

<blockquote>
  <p>kubectl create configmap console-configmap
  --from-file=./config/console-server.yml</p>
  
  <p>kubectl describe configmap console-configmap</p>
</blockquote>

<p>below are the description details:</p>

<pre><code>Name:         console-configmap
Namespace:    default
Labels:       &lt;none&gt;
Annotations:  &lt;none&gt;

Data
====
console-server.yml:
----
server:
  http:
    port: 8385
  compression:
    enabled: true
    mime-types: application/json,application/xml,text/html,text/xml,text/plain,text/css,application/javascript
    min-response-size: 2048

---
spring:
  thymeleaf:
    prefix: classpath:/static
  application:
    name: console-service
  profiles:
     active: native
  servlet:
    multipart:
      max-file-size: 30MB
      max-request-size: 30MB
---
host:
  gateway: http://apigateway:4000
  webhook: http://localhost:9000
</code></pre>

<p>my deployment yml is:</p>

<pre><code>apiVersion: apps/v1 # for versions before 1.8.0 use apps/v1beta1
kind: Deployment
metadata:
  name: consoleservice1
spec:
  selector:
    matchLabels:
      app: consoleservice
  replicas: 1 # tells deployment to run 3 pods matching the template
  template: # create pods using pod definition in this template
    metadata:
      labels:
        app: consoleservice
    spec:
      containers:
      - name: consoleservice
        image: ms-console
        ports:
        - containerPort: 8384
        imagePullPolicy: Always
        envFrom:
        - configMapRef:
            name: console-configmap
      imagePullSecrets:
        - name: regcresd
</code></pre>

<p>My doubt is, I commented config folder in the Dockerfile, so while running pods, it's throwing exception because of no configuration, how I will inject this console-configmap to my deployment, what I tried already shared, but getting same issues.</p>

Chintamani
<p>First of all, how are you consuming the .yml file in your application? If you consume your yml file contents as environment variables, your config should just work fine. But I suspect that you want to consume the contents from the config file inside the container. If that is the case you have to create a volume out of the configmap as follows:</p>

<pre><code>
apiVersion: apps/v1 # for versions before 1.8.0 use apps/v1beta1
kind: Deployment
metadata:
  name: consoleservice1
spec:
  selector:
    matchLabels:
      app: consoleservice
  replicas: 1 # tells deployment to run 3 pods matching the template
  template: # create pods using pod definition in this template
    metadata:
      labels:
        app: consoleservice
    spec:
      containers:
      - name: consoleservice
        image: ms-console
        ports:
        - containerPort: 8384
        imagePullPolicy: Always
        volumeMounts:
          - mountPath: /app/config
            name: config
      volumes:
        - name: config
          configMap:
            name: console-configmap
      imagePullSecrets:
        - name: regcresd
</code></pre>

<p>The file will be available in the path <code>/app/config/console-server.yml</code>. You have to modify it as per your needs.</p>
