codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🍃

Spring Boot

50 / 62 topics
47Kubernetes Basics for Spring Boot Applications48Creating a Kubernetes Deployment49Using Kubernetes Services50Using ConfigMaps in Kubernetes51Using Secrets in Kubernetes
Tutorials/Spring Boot/Using ConfigMaps in Kubernetes
🍃Spring Boot

Using ConfigMaps in Kubernetes

Updated 2026-05-15
10 min read

Using ConfigMaps in Kubernetes

Introduction

In the world of container orchestration, managing configurations efficiently is crucial. Kubernetes provides a powerful mechanism called ConfigMaps to handle application configuration data separately from your application code. This separation allows for easier management and updates without needing to rebuild or redeploy your applications.

This tutorial will guide you through understanding what ConfigMaps are, how they work, and how to use them effectively in your Kubernetes environment. Whether you're a beginner or an intermediate developer, this content should provide you with the knowledge needed to manage configurations using ConfigMaps.

Concept

What is a ConfigMap?

A ConfigMap is an API object used to store non-confidential data in key-value pairs. Pods can consume ConfigMaps as environment variables, command-line arguments, or as configuration files in a volume. This makes it easy to separate configuration from your application code and manage configurations across different environments.

Why Use ConfigMaps?

  1. Separation of Concerns: By using ConfigMaps, you keep your application code clean and focused on its core functionality.
  2. Environment Management: Easily switch between different configurations for development, testing, and production environments.
  3. Dynamic Configuration Updates: Update configurations without needing to restart or redeploy your applications.

Examples

Creating a ConfigMap

Let's start by creating a simple ConfigMap that stores some application configuration data.

Terminal
Output
Name:         my-config
Namespace:    default
Labels:       <none>
Annotations:  <none>

Data
====
app.name:
----
my-app

app.version:
-----
1.0.0

Using ConfigMap as Environment Variables

You can use the values from a ConfigMap as environment variables in your Pods.

Here's an example of a Pod configuration that uses my-config as environment variables:

YAML
1apiVersion: v1
2kind: Pod
3metadata:
4name: my-pod
5spec:
6containers:
7 - name: my-container
8 image: nginx
9 env:
10 - name: APP_NAME
11 valueFrom:
12 configMapKeyRef:
13 name: my-config
14 key: app.name
15 - name: APP_VERSION
16 valueFrom:
17 configMapKeyRef:
18 name: my-config
19 key: app.version

Apply this configuration using:

Terminal

Accessing ConfigMap Data

Once your Pod is running, you can access the ConfigMap data as follows:

For environment variables:

Terminal
Output
my-app

What's Next?

Now that you have a good understanding of how to use ConfigMaps in Kubernetes, the next step is to explore Secrets. Secrets are similar to ConfigMaps but are used for storing sensitive information like passwords and API keys. Learn how to manage sensitive data securely using Secrets in your Kubernetes environment.

Happy coding!


PreviousUsing Kubernetes ServicesNext Using Secrets in Kubernetes

Recommended Gear

Using Kubernetes ServicesUsing Secrets in Kubernetes