How to define complex list for kubernetes config map

8/31/2021

I have this scenario in my spring boot yaml file:

bootstrap.yaml

This way I'm able to load the properties in config file to memory.

enter image description here

Now I need to apply this same configuration to my config map kubernetes file.

I have found this example in kubernetes official documentation, but is different from what a I need.

https://kubernetes.io/docs/concepts/configuration/configmap/#configmaps-and-pods

enter image description here

Are there some way to apply the configuration in config map as is in my first image ?

-- Yuri.stpsa
configmap
kubernetes
spring-boot

1 Answer

8/31/2021

Yes, of course - use your application.yaml as input.

kubectl create configmap demo --from-file application.yaml

You can mount the file in a container again as application.yaml and you're done.

The generated configmap looks like this:

apiVersion: v1
kind: ConfigMap
data:
  application.yaml: |+
    my-company:
      kafka:
        some-propery-1: 10
      topics:
      - foo: bar

By the way: Please don't post screenshots with code, this makes the content inaccessible to screen readers and search engines.

-- Thomas
Source: StackOverflow