0
0
Kubernetesdevops~30 mins

Creating ConfigMaps from files in Kubernetes - Try It Yourself

Choose your learning style9 modes available
Creating ConfigMaps from files
📖 Scenario: You are managing a Kubernetes cluster for a small web application. You want to store configuration data in ConfigMaps by loading it from files on your local machine. This helps keep your app settings organized and separate from your container images.
🎯 Goal: Learn how to create a Kubernetes ConfigMap from files using the kubectl create configmap command with the --from-file option. You will create a ConfigMap named app-config from two configuration files.
📋 What You'll Learn
Create two configuration files named app.properties and db.properties with specific content.
Use kubectl create configmap with --from-file to create a ConfigMap named app-config from these files.
Verify the ConfigMap was created and contains the correct data.
💡 Why This Matters
🌍 Real World
Storing configuration data separately from application code is a common practice in Kubernetes. ConfigMaps allow you to manage settings easily and update them without rebuilding container images.
💼 Career
Knowing how to create and manage ConfigMaps from files is essential for Kubernetes administrators and DevOps engineers to configure applications dynamically and maintain clean deployment workflows.
Progress0 / 4 steps
1
Create configuration files
Create two files named app.properties and db.properties with the exact content below:

app.properties content:
app.name=MyApp
app.version=1.0

db.properties content:
db.host=localhost
db.port=5432
Kubernetes
Need a hint?

Use the echo command with redirection > to create files with content.

2
Create ConfigMap from files
Use the command kubectl create configmap app-config --from-file=app.properties --from-file=db.properties to create a ConfigMap named app-config from the two files.
Kubernetes
Need a hint?

Use kubectl create configmap with --from-file option for each file.

3
Verify the ConfigMap contents
Use the command kubectl get configmap app-config -o yaml to display the ConfigMap details and verify it contains keys app.properties and db.properties.
Kubernetes
Need a hint?

Use kubectl get configmap with -o yaml to see full details.

4
Display ConfigMap keys
Use the command kubectl get configmap app-config -o jsonpath='{.data}' to print only the data keys and their values stored in the ConfigMap.
Kubernetes
Need a hint?

Use -o jsonpath='{.data}' to extract only the data field from the ConfigMap.