Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Configuring Spring Boot Application on Kubernetes

 

October 2, 2017
Kamesh Sampath
Related topics:
JavaKubernetesMicroservicesSpring Boot
Related products:
Red Hat OpenShift Container Platform

Share:

    When the developers plan to deploy Spring Boot application on Kubernetes, the first question comes to a spring developer's mind is "Can I use Spring Config server?" Spring Config server is a de-facto way of doing centralized configuration of a distributed application. Yes, we can use Spring Config server, but let’s think of some constraints that Spring Config server can have in a typical Enterprise deployment:

    • No access to the internet from production.
      • This means I can’t use the default Git backed if the customer uses other VCS.
    • Running own ConfigServer locally is another possibility.
      • But then you need to deploy to set it up in each environment and then applying policies, rules, etc.
    • Restricting access to config server properties and files.
      • Typically like making *-prod not visible to other environment users or file permissions.
    • What are other backends that I can use?
      • If I need to add a new backend how or what customization do I need to make to my config server. 
    • I can't mount the Spring Config server hosted properties as Volumes/Files.

    Though there might be or will be a workaround to overcome these constraints, but as a Developer, I would prefer to use something that my platform provides natively rather than customizing it myself. The big advantage to using the native way clear separation of concern, where I was a Developer, I don’t need to worry about how the configuration is available to me but just be assured I will have it! Are there are better ways to do the same inside Kubernetes? The answer is affirmative :). OK then,

    1. What are they?  
    2. How do I use them?
    3. What backend can I use with it?
    4. Is it secured?
    5. Can Spring Boot use them?
    6. Can those kinds of properties be hot reloaded?

    To answer all those questions is why I decided to write this blog series "Configuring Spring Boot Application on Kubernetes".

    Before we jump into details let me answer some of the questions asked above.

    What are they?

    In Kubernetes, we can handle all the application configuration and properties using ConfigMaps and Secrets. Using ConfigMaps and Secrets, the application naturally satisfies Config principle of The Twelve-Factor App.

    How do I use them?

    There are many ways to use them, but we will be focusing on two simple methods of using theme i.e.

    • As Environment Variables
    • As Files inside the containers

    What backend do they support?

    When ConfigMaps and Secrets  can be loaded as files from various backends like S3, CephFS, GlusterFS, NFS and much more.  More details are available at https://kubernetes.io/docs/concepts/storage/volumes/. 

    Is it secured?

    Using ConfigMaps and Secrets as files are the easiest ways to make ConfigMaps and Secrets secured. We can apply for the file/directory permissions. We can also restrict the access based on the Namespace synonymous to environments and Service Accounts.

    To answer the question “Can Spring Boot use them?”, I have split the blog series into two parts, with each dedicated to ConfigMaps and Secrets. 

    The blog posts provide the details demo sources. The README on the source repos helps you to try things by yourself (DIY).

    The Spring Boot and Kubernetes Series

    How to Configure the Spring Boot Application on Kubernetes

    Part I: Configuring Spring Boot on Kubernetes with ConfigMap

    Part II: Configuring Spring Boot Kubernetes Secrets

    Last updated: March 22, 2023

    Recent Posts

    • What qualifies for Red Hat Developer Subscription for Teams?

    • How to run OpenAI's gpt-oss models locally with RamaLama

    • Using DNS over TLS in OpenShift to secure communications

    • Scaling DeepSeek and Sparse MoE models in vLLM with llm-d

    • Multicluster authentication with Ansible Automation Platform

    What’s up next?

     

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue