OpenShift: change ConfigMap in java runtime

11/22/2019

I have a java app running in OpenShift pod. And I have ConfigMap with some data.

My app need to change some information in this ConfigMap while runtime when http-request received.

Is this possible? And where this ConfigMap is stored, so can I read it in my java-app as simple file (File file = new File(/ConfigMapPath)) and then change it ?

Any help, thanks

-- Sasha Korkin
java
kubernetes
openshift

1 Answer

11/22/2019

OpenShift is based on Kubernetes so everything below as it relates to ConfigMap-s applies to both.

Kubernetes saves ConfigMap-s in its backing data store for all cluster data - etcd by default.

A ConfigMap can me mounted as a volume and its entries accessed as files. However, updates to those files will not be reflected back into the ConfigMap.

It is possible to change ConfigMap-s from a Java application running in a Pod Container using the REST API and with proper access.

-- gears
Source: StackOverflow