Kubernetes config map for Spring boot application.properties

3/24/2018

I have many spring boot application which i want to deploy in Kubernetes cluster. I came across an option to use file based config map. I am not clear on this. I am looking for to import the entire application.properties for each application and should be able to refer that in the corresponding service. There could be chances for the same keys in different application.properties. Not sure how to load the complete application.properties file by application and just refer from corresponding service.

Also, How can i secure this application.proerties so that only the corresponding application can refer this?

Thanks

-- user1578872
kubernetes

1 Answer

3/25/2018

Kubernetes has a special place for that kind of data - Secret.

That type of objects is visible only in Namespace where it's created so you can run your applications in different namespaces and each application will able to use only secrets in its namespace.

Also, you can encrypt your secrets.

So, first of all, you need to create a secret with your data:

kubectl create secret generic <secret-name> --from-file=<file-you-want-to-create-as-a-secret>

You can also include several files into one secret. In a documentation, you can find an example.

Now, you can mount your secrets into a Spark app to the executor and, if you want, to the driver:

--conf spark.kubernetes.driver.secrets.<secret-name>=<path/in/container>
--conf spark.kubernetes.executor.secrets.<secret-name>=/etc/secrets

After that, you can use your secrets in the application as regular files.

-- Anton Kostenko
Source: StackOverflow