Ignore specify slash character in yaml config for spring boot admin application

Tags: , ,



I want to configure the service label app.kubernetes.io/part-of: myapp for the kubernetes discovery in my spring boot admin application.

app.kubernetes.io/part-of is a recommended label, so I think there should be a way to configure it for the service discovery.

spring:
    cloud:
        kubernetes:
            discovery:
                namespace: myspace
                all-namespaces: true
                service-labels:
                    'app.kubernetes.io/part-of': myapp

Unfortunately all special characters are removed in the yaml keys, which I notice in the configprops actuator.

My questions:

  • How can I specify a slash in a yaml key for spring boot?
  • Is there an alternative solution to specify my service label?

Hints:

  • Other general yaml questions, which suggest to escape or quote the characters, does not help here. Or I missed something.

Answer

You can encode it with square brackets

"[app.kubernetes.io/part-of]": myapp


Source: stackoverflow