Replace Spring properties with environment variables in Kubernetes

Albert Giró published on
1 min, 59 words

Categories: Tips

We could override any springboot in runtime defining environment variables in kubernetes. For example, if we need to override loging level of our app defined in own application.properties like.

logging.level.org.springframework=DEBUG

We will define a new environment variable in snake_case like LOGGING_LEVEL_ORG_SPRINGFRAMEWORK in our deployment definition as follow.

        env:
            - nameSPRING_PROFILES_ACTIVE
               valuedev
            - nameLOGGING_LEVEL_ORG_SPRINGFRAMEWORK
              valueDEBUG