简体   繁体   中英

How to set null value using config map in spring boot applicaton

I follow this and this example to run spring boot applicaton in kube with reloading config map. When I set value everything is OK. But when I want set null or delete value from map then nothing happens

for example my init config map is:

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-app
data:
  application.yaml: |-
    config:
      testicek: stringvalue123
      inticek: 123

but when I change it to aand apply config map:

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-app
data:
  application.yaml: |-
    config:
      testicek: null
      inticek: null

then testicek what is String contains empty string not null and inticek what is Integer was not even refreshed and still contain old value. Any tips how to fix this?

UPDATE

so I found why null is solved as empty string here . So after 4 years there is still no hook point how to change this behavior? And even worse when I want to change Integer to null then nothing happens because, I guess, Integer can not be empty so setter of my property is not even called after configMap is changed

Fortunately, the example that you are following is using Deployment and not vanilla Pod . This means you can do the rolling update of the new revision as following:

kubectl rollout restart deployment/minikube-sample

You can auto-schedule the Reload of deployment using the Reloader.

The reloader will watch the configmap and secret.

Please checkout: https://github.com/stakater/Reloader

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM