{"id":932,"date":"2020-08-21T12:24:01","date_gmt":"2020-08-21T12:24:01","guid":{"rendered":"https:\/\/blog.samarthya.me\/wps\/?p=932"},"modified":"2020-08-21T12:24:02","modified_gmt":"2020-08-21T12:24:02","slug":"configmaps-k8s-2","status":"publish","type":"post","link":"https:\/\/blog.samarthya.me\/wps\/2020\/08\/21\/configmaps-k8s-2\/","title":{"rendered":"ConfigMaps: K8S &#8211; 2"},"content":{"rendered":"<p>We looked at using the environment variables using the configmap in the last <a href=\"https:\/\/blog.samarthya.me\/wps\/2020\/08\/20\/configmap-k8s\/\">blog<\/a>.<\/p>\n\n\n<p>The config map remains the same but now in YAML.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: happy-faces-mnt\ndata:\n  data.values: |-\n    my.name=saurabh\n    my.profession=engineer<\/code><\/pre>\n\n\n\n<p>I will use this to mount it to a container and then see the contents of the file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apiVersion: v1\nkind: Pod\nmetadata:\n  name: happy-pod\nspec:\n  containers:\n  - name: bbox-pod\n    image: busybox:latest\n    command: &#91;'sh','-c',\"echo hello world! &amp;&amp; sleep 3600\"]\n    volumeMounts:\n    - name: my-volume\n      mountPath: \/etc\/values\n      readOnly: true\n  volumes:\n  - name: my-volume\n    configMap:\n      name: happy-faces-mnt<\/code><\/pre>\n\n\n\n<p>Have added a <code>volume<\/code> and <code>mount<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>volumes:\n  - name: my-volume\n    configMap:\n      name: happy-faces-mnt<\/code><\/pre>\n\n\n\n<p>configMap listing for my machine is as under<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>k get cm\nNAME              DATA   AGE\nhappy-faces-mnt   1      36m<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>k describe cm\n\nName:         happy-faces-mnt\nNamespace:    default\nLabels:       &lt;none>\nAnnotations:  \nData\n====\ndata.values:\n----\nmy.name=saurabh\nmy.profession=engineer\nEvents:  &lt;none><\/code><\/pre>\n\n\n\n<p>Run the pod<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>k get pods\nNAME        READY   STATUS    RESTARTS   AGE\nhappy-pod   1\/1     Running   0          8m21s<\/code><\/pre>\n\n\n\n<p>Check the mounted volume using<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>k exec pod\/happy-pod -- cat \/etc\/values\/data.values\nmy.name=saurabh\nmy.profession=engineer<\/code><\/pre>\n\n\n\n<p>The content of the file are shown.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We looked at using the environment variables using the configmap in the last blog. The config map remains the same but now in YAML. I will use this to mount it to a container and then see the contents of the file. Have added a volume and mount. configMap listing for my machine is as [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":935,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[34],"tags":[95,18],"class_list":["post-932","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-technical","tag-configmap","tag-k8s","post_format-post-format-image"],"_links":{"self":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/comments?post=932"}],"version-history":[{"count":0,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/932\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media\/935"}],"wp:attachment":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media?parent=932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/categories?post=932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/tags?post=932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}