0
0
Kubernetesdevops~15 mins

Creating ConfigMaps from literals in Kubernetes - Try It Yourself

Choose your learning style9 modes available
Creating ConfigMaps from literals
📖 Scenario: You are managing a Kubernetes cluster for a small web application. You need to store configuration settings like the application mode and log level using ConfigMaps. This helps keep your app settings separate from the code.
🎯 Goal: Create a ConfigMap using literal values to store application configuration settings. Then, display the ConfigMap details to verify your work.
📋 What You'll Learn
Create a ConfigMap named app-config with two literals: mode=production and log_level=info
Use the kubectl create configmap command with the --from-literal option
Display the created ConfigMap using kubectl get configmap app-config -o yaml
💡 Why This Matters
🌍 Real World
ConfigMaps are used in Kubernetes to separate configuration from application code, making apps easier to manage and update without rebuilding images.
💼 Career
Knowing how to create and manage ConfigMaps is essential for Kubernetes administrators and DevOps engineers to configure applications dynamically.
Progress0 / 4 steps
1
Create ConfigMap with literals
Use the kubectl create configmap command to create a ConfigMap named app-config with the literals mode=production and log_level=info.
Kubernetes
Need a hint?

Remember to use kubectl create configmap with --from-literal for each key-value pair.

2
Add a label to the ConfigMap
Add a label env=production to the ConfigMap creation command by including the --labels option.
Kubernetes
Need a hint?

Use --labels=env=production to add a label during creation.

3
Retrieve the ConfigMap details
Use the command kubectl get configmap app-config -o yaml to display the full details of the app-config ConfigMap.
Kubernetes
Need a hint?

Use kubectl get configmap app-config -o yaml to see the ConfigMap content in YAML format.

4
Display the ConfigMap output
Run the command kubectl get configmap app-config -o yaml and show the output that includes the literals mode: production and log_level: info.
Kubernetes
Need a hint?

The output should show the ConfigMap data with keys mode and log_level and their values.