-1

New to k8s.

My configmap looks like

apiVersion: v1
kind: ConfigMap
metadata:
    name: example-configmap-overriding-new-01
data:
    application.properties: |
        globalkey = global key value
        TeamName = Team Name value  
        #Some other key value pairs         
    application-qa.properties: |
        globalkey = global key qa value
        TeamName = Team Name qa value
        #Some other key value pairs
    application-prod.properties: |
        globalkey = global key prod value
        Company = company prod value
        #Some other key value pairs

While trying to use this config map in my spring boot application, app is not picking up the value from the configmap. It says,

Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: 
Could not resolve placeholder 'globalkey' in value "${globalkey}"

Posted that question HERE.

Unfortunatly, saw the env varibles injected inside the container by the configmap. Shared the logs for reference.

application.properties=globalkey = global key value
TeamName = Team Name value
Purpose = Purpose value
RootFile = Root file value
Company = company value
Place = Place value
Country = Country value

application-prod.properties=globalkey = global key prod value
Company = company prod value
Place = Place prod value
Country = Country prod value

application-qa.properties=globalkey = global key qa value
TeamName = Team Name qa value
Purpose = Purpose qa value
RootFile = Root file qa value

#Some other key values pairs injected by k8s

I believe, from the logs, "application.properties=globalkey = global key value", have not seen such key value pair.

Suspect, something went wrong in injecting the configmap. Is there any syntax mistake or?

PS:- I also tried the following syntax too.

apiVersion: v1
kind: ConfigMap
metadata:
    name: example-configmap-overriding-new-01
data:
    application.properties: |-
        globalkey = global key value                    
    application-qa.properties: |-
        globalkey = global key qa value

I am using minikube for local development in windows 10 pro machine.

Could some one share insights here.

PS: I am asking why env variable is displayed as "application.properties=globalkey = global key value" and I also linked the origin of the question. In old question, I asked like "cannot read from configmap". In new question, I asked like, "multi profile config map is not properly injected to container"

NANDAKUMAR THANGAVELU
  • 611
  • 3
  • 15
  • 34
  • The question is already answered in his previous question : https://stackoverflow.com/questions/56863782/cannot-read-configmap-with-name-xx-in-namespace-default-ignoring Using volumeMount with configmap is the solution as suggested in the above question. – Malathi Jul 04 '19 at 09:28
  • Possible duplicate of [Cannot read configmap with name: \[xx\] in namespace \['default'\] Ignoring](https://stackoverflow.com/questions/56863782/cannot-read-configmap-with-name-xx-in-namespace-default-ignoring) – Malathi Jul 04 '19 at 09:29
  • @Malathi: Thx for the comments. I have already tagged the "https://stackoverflow.com/questions/56863782/cannot-read-configmap-with-name-xx-in-namespace-default-ignoring" in this question. Both the old question and new question are different and the question which I asked in both place are different. I have got no answer for any of the question yet. "Using volumeMount with configmap is the solution as suggested in the above question" - This is not working and I commented the same. Appreciate, to go through the question before downvoting! Thx. – NANDAKUMAR THANGAVELU Jul 04 '19 at 17:47

1 Answers1

0

There are some syntax mistakes with your ConfigMap. Please, try this:

apiVersion: v1
kind: ConfigMap
metadata:
  name: example-configmap-overriding-new-01
  namespace: <insert_namespace_here>
data:
  application.properties: |
    globalkey=global-key-value
    TeamName=Team-Name-value  
    #Some other key value pairs         
  application-qa.properties: |
    globalkey=global-key-qa-value
    TeamName=Team-Name-qa-value
    #Some other key value pairs
  application-prod.properties: |
    globalkey=global-key-prod-value
    Company=company-prod-value
    #Some other key value pairs

If you are not sure about your configuration, please see this documentation. There are plenty of examples.

Please let me know if that helped.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37