↓ Skip to main content
Kubernetes

ConfigMaps: K8S - 2

·1 min

We looked at using the environment variables using the configmap in the last blog.

The config map remains the same but now in YAML.

apiVersion: v1
kind: ConfigMap
metadata:
  name: happy-faces-mnt
data:
  data.values: |-
    my.name=samarthya
    my.profession=engineer

I will use this to mount it to a container and then see the contents of the file.

apiVersion: v1
kind: Pod
metadata:
  name: happy-pod
spec:
  containers:
  - name: bbox-pod
    image: busybox:latest
    command: ['sh','-c',"echo hello world! && sleep 3600"]
    volumeMounts:
    - name: my-volume
      mountPath: /etc/values
      readOnly: true
  volumes:
  - name: my-volume
    configMap:
      name: happy-faces-mnt

Have added a volume and mount.

volumes:
  - name: my-volume
    configMap:
      name: happy-faces-mnt

configMap listing for my machine is as under

k get cm
NAME              DATA   AGE
happy-faces-mnt   1      36m
k describe cm

Name:         happy-faces-mnt
Namespace:    default
Labels:       <none>
Annotations:  
Data
====
data.values:
----
my.name=samarthya
my.profession=engineer
Events:  <none>

Run the pod

k get pods
NAME        READY   STATUS    RESTARTS   AGE
happy-pod   1/1     Running   0          8m21s

Check the mounted volume using

k exec pod/happy-pod -- cat /etc/values/data.values
my.name=samarthya
my.profession=engineer

The content of the file are shown.

Author
Samarthya
Engineer, learner, tinkerer. This is my trophy shelf of everyday work and leisure.

Related

K8S

·1 min
What is K8S? # To manage distributed containerised workloads, you use Kubernetes. It is resilient declarative configuration. It is open source platform. It allows you to bundle and run your application. From the official Kubernetes documentation. Kubernetes objects # K8S objects are the persistent entities in the K8S system and thee entities are used to represent the state of the cluster.

PV, PVC

·1 min
PV and PVC: PersistentVolume and PersistentVolumeClaim # PV - Defines the structure for provisioning storage for use. They have a defined lifecycle, independent of any individual Pod that uses the PV.

Kubectl - A revisit

·3 mins
It is always fun learning and trying out some new tech. In this blog, I will try and capture my experience of running my first pod using kubectl. If you wish to learn how to install a typical master, worker cluster of K8S I recommend going through this blog.