Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      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
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java 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

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • 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

    • Introducing Red Hat build of Cryostat 4.0

    • How we improved AI inference on macOS Podman containers

    • How OpenShift Virtualization supports VM live migration

    • How SELinux deny rules improve system security

    • Advanced time manipulation with GDB

    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

    Red Hat legal and privacy links

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

    Report a website issue