0% found this document useful (0 votes)
6 views2 pages

003 Lesson Reference

This document discusses the configuration of applications in Kubernetes using ConfigMaps and secrets. It provides step-by-step instructions on creating a ConfigMap and a secret, as well as how to create a pod that utilizes this configuration data. The document also includes examples of the expected output when logging the configuration data from the pod.

Uploaded by

Jordan KONTIO
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

003 Lesson Reference

This document discusses the configuration of applications in Kubernetes using ConfigMaps and secrets. It provides step-by-step instructions on creating a ConfigMap and a secret, as well as how to create a pod that utilizes this configuration data. The document also includes examples of the expected output when logging the configuration data from the pod.

Uploaded by

Jordan KONTIO
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

App Configuration in Kubernetes

Application configuration is a necessary part of any infrastructure. In this lesson, we will discuss how to configure applications
running on Docker Kubernetes Service. We will talk about ConfigMaps and secrets, and how to use them to expose
configuration data to our containers.

Relevant Documentation

ConfigMaps
Secrets

Lesson Reference

Access UCP in a browser at [Link] .

We can create Kubernetes objects in UCP by navigating to Kubernetes > + Create. Make sure to use the default namespace
throughout this exercise.

Create a ConfigMap:

apiVersion: v1
kind: ConfigMap
metadata:
name: my-configmap
data:
key1: important data
[Link]: |
Another value
multiple lines
more lines

Create a secret:

apiVersion: v1
kind: Secret
metadata:
name: my-secret
type: Opaque
data:
username: dXNlcgo=
password: ZG9ja2VyCg==

Create a pod that uses the configuration data from the ConfigMap and secret:

apiVersion: v1
kind: Pod
metadata:
name: my-configured-pod
spec:
restartPolicy: Never
containers:
- name: busybox
image: busybox
command: ["sh", "-c", "echo \"ConfigMap environment variable: $CONFIGMAPVAR\" && echo \"Secret
environment variable: $SECRETVAR\" && echo \"The ConfigMap mounted file is: $(cat /etc/configmap/
[Link])\" && echo \"The Password is:\" $(cat /etc/secret/password)"]
env:
- name: CONFIGMAPVAR
valueFrom:

configMapKeyRef:
name: my-configmap
key: key1
- name: SECRETVAR
valueFrom:
secretKeyRef:
name: my-secret
key: username
volumeMounts:
- name: configmap-vol
mountPath: /etc/configmap
- name: secret-vol
mountPath: /etc/secret
volumes:
- name: configmap-vol
configMap:
name: my-configmap
- name: secret-vol
secret:
secretName: my-secret

Click on the my-configured-pod pod.

Click the Log icon near the upper right.

We should see our configuration data printed to the log, both from the ConfigMap and the secret, like so:

ConfigMap environment variable: important data

Secret environment variable: user

The ConfigMap mounted file is:Another value

multiple lines

more lines

The Password is: docker

You might also like