How do I override per-instance settings in Spring Boot Admin when using Kubernetes discovery How do I override per-instance settings in Spring Boot Admin when using Kubernetes discovery kubernetes kubernetes

How do I override per-instance settings in Spring Boot Admin when using Kubernetes discovery


I think I figured this out for myself, but in case it's useful to anyone else here is what I did:

  • Declared custom values for the instance metadata management.context-path, user.name and user.password under the annotations section of the Kubernetes service for my client application.

e.g.

kind: ServiceapiVersion: v1metadata:  name: foo-service  annotations:    # The following are used to support monitoring and administration    user.name: mySpecialUsername    user.password: mySpecialPassword    management.context-path: /foo/manage

From observation it seems that the default credentials assumed by a Spring Boot Administration server are admin/admin.


I don't think it is advisable to put passwords into a service manifest.The SBA refdoc documents some properties to configure default or per service usernames/passwords.

If this is not an option, you can always add some custom headers to the requests that are sent to the clients:

@Beanpublic HttpHeadersProvider customHttpHeadersProvider() {    return (instance) -> {        HttpHeaders httpHeaders = new HttpHeaders();        httpHeaders.add("Authorization", "Basic bXlTcGVjaWFsVXNlcm5hbWU6bXlTcGVjaWFsUGFzc3dvcmQ=");        return httpHeaders;    };}