Mounting ConfigMaps in Spring Cloud Data flow deployed in Kubernetes

5/14/2020

I am using Spring Cloud Data flow for microservice orchestration and deploying them in Kubernetes. My apps pipeline looks something like below: Source-app --> Processor-app --> Sink-app

I am able to create and deploy the stream and it successfully creates deployments and pods and my pipeline works fine with below SCDF deployer properties:

app.Source-app.deployer.kubernetes.livenessProbePath=/api/v1/actuator/health
app.Source-app.deployer.kubernetes.readinessProbePath=/api/v1/actuator/info
app.Source-app.server.port=8080
app.Processor-app.deployer.kubernetes.livenessProbePath=/api/v1/actuator/health
app.Processor-app.deployer.kubernetes.readinessProbePath=/api/v1/actuator/info
app.Processor-app.server.port=8080
app.Sink-app.deployer.kubernetes.livenessProbePath=/api/v1/actuator/health
app.Sink-app.deployer.kubernetes.readinessProbePath=/api/v1/actuator/info
app.Sink-app.server.port=8080
deployer.*.kubernetes.liveness-probe-path=/api/v1/actuator/health
deployer.*.kubernetes.readiness-probe-path=/api/v1/actuator/info

Now my requirement is, I want to store all the above configurations in a ConfigMap in Kubernetes and just refer or mount that ConfigMap in SCDF deployer properties window. I know we can refer using configMapKeyRefs as environment variable(with limitation for only String values) like:

deployer.Source-app.kubernetes.configMapKeyRefs=[{envVarName: 'LIVENESSPROBEPATH', configMapName: 'test-conf', dataKey: 'livenessProbePath }]
app.Source-app.deployer.kubernetes.livenessProbePath=$(LIVENESSPROBEPATH) 

... So on for each property...

But this we need to do for each and every property. I am looking for something like, mention all the properties in a configMap and just refer or mount that ConfigMap while deploying stream in SCDF and voila! all your properties are passed to the apps. I was referring the official docs and reading about volumeMounts and persistentVolumes but not very clear. If someone could provide a solution for my usecase, it would be of great help.

-- Sumit
configmap
kubernetes
spring-cloud-dataflow

1 Answer

5/14/2020

consider you have configmap something like this :

apiVersion: v1
data:
  USER_ID: "1"
  USER_EMAIL: user@mail.com
  IS_DATA_ENABLED : "True"
kind: ConfigMap
metadata:
  name: staging-configmap
  namespace: default

you can inject all property in deployment with

envFrom:
        - secretRef:
            name: test-secret
        - configMapRef:
            name: staging-configmap

if you have secret also you can mount or inject secret also to deployment and its variable set OS. using configMapRef it will add all the properties of config-map to deployment.

-- Harsh Manvar
Source: StackOverflow