@@ -403,6 +403,8 @@ For example, to generate a ConfigMap from files `configure-pod-container/configm
403
403
cat <<EOF >./kustomization.yaml
404
404
configMapGenerator:
405
405
- name: game-config-4
406
+ labels:
407
+ game-config: config-4
406
408
files:
407
409
- configure-pod-container/configmap/game.properties
408
410
EOF
@@ -435,7 +437,7 @@ kubectl describe configmaps/game-config-4-m9dm2f92bt
435
437
```
436
438
Name: game-config-4-m9dm2f92bt
437
439
Namespace: default
438
- Labels: <none>
440
+ Labels: game-config=config-4
439
441
Annotations: kubectl.kubernetes.io/last-applied-configuration:
440
442
{"apiVersion":"v1","data":{"game.properties":"enemies=aliens\nlives=3\nenemies.cheat=true\nenemies.cheat.level=noGoodRotten\nsecret.code.p...
441
443
@@ -467,6 +469,8 @@ with the key `game-special-key`
467
469
cat << EOF >./kustomization.yaml
468
470
configMapGenerator:
469
471
- name: game-config-5
472
+ labels:
473
+ game-config: config-5
470
474
files:
471
475
- game-special-key=configure-pod-container/configmap/game.properties
472
476
EOF
@@ -505,6 +509,15 @@ kubectl apply -k .
505
509
configmap/special-config-2-c92b5mmcf2 created
506
510
```
507
511
512
+ ## Interim cleanup
513
+
514
+ Before proceeding, clean up some of the ConfigMaps you made:
515
+
516
+ ``` bash
517
+ kubectl delete configmap special-config
518
+ kubectl delete configmap env-config
519
+ kubectl delete configmap -l ' game-config in (config-4,config-5)’
520
+ ```
508
521
509
522
Now that you have learned to define ConfigMaps, you can move on to the next
510
523
section, and learn how to use these objects with Pods.
@@ -558,6 +571,11 @@ Here is the manifest you will use:
558
571
559
572
Now, the Pod' s output includes environment variables `SPECIAL_LEVEL_KEY=very` and `LOG_LEVEL=INFO`.
560
573
574
+ Once you' re happy to move on, delete that Pod:
575
+ ` ` ` shell
576
+ kubectl delete pod dapi-test-pod --now
577
+ ` ` `
578
+
561
579
# # Configure all key-value pairs in a ConfigMap as container environment variables
562
580
563
581
* Create a ConfigMap containing multiple key-value pairs.
@@ -570,6 +588,7 @@ Here is the manifest you will use:
570
588
kubectl create -f https://kubernetes.io/examples/configmap/configmap-multikeys.yaml
571
589
` ` `
572
590
591
+
573
592
* Use ` envFrom` to define all of the ConfigMap' s data as container environment variables. The
574
593
key from the ConfigMap becomes the environment variable name in the Pod.
575
594
@@ -583,6 +602,11 @@ Here is the manifest you will use:
583
602
Now, the Pod' s output includes environment variables ` SPECIAL_LEVEL=very` and
584
603
` SPECIAL_TYPE=charm` .
585
604
605
+ Once you' re happy to move on, delete that Pod:
606
+ ```shell
607
+ kubectl delete pod dapi-test-pod --now
608
+ ```
609
+
586
610
## Use ConfigMap-defined environment variables in Pod commands
587
611
588
612
You can use ConfigMap-defined environment variables in the `command` and `args` of a container
@@ -605,6 +629,11 @@ That pod produces the following output from the `test-container` container:
605
629
very charm
606
630
```
607
631
632
+ Once you' re happy to move on, delete that Pod:
633
+ ` ` ` shell
634
+ kubectl delete pod dapi-test-pod --now
635
+ ` ` `
636
+
608
637
# # Add ConfigMap data to a Volume
609
638
610
639
As explained in [Create ConfigMaps from files](# create-configmaps-from-files), when you create
@@ -651,6 +680,11 @@ If there are any files in the `/etc/config` directory of that container image, t
651
680
mount will make those files from the image inaccessible.
652
681
{{< /note >}}
653
682
683
+ Once you' re happy to move on, delete that Pod:
684
+ ` ` ` shell
685
+ kubectl delete pod dapi-test-pod --now
686
+ ` ` `
687
+
654
688
# ## Add ConfigMap data to a specific path in the Volume
655
689
656
690
Use the ` path` field to specify the desired file path for specific ConfigMap items.
@@ -674,6 +708,12 @@ very
674
708
Like before, all previous files in the ` /etc/config/` directory will be deleted.
675
709
{{< /caution > }}
676
710
711
+ Delete that Pod:
712
+ ` ` ` shell
713
+ kubectl delete pod dapi-test-pod --now
714
+ ` ` `
715
+
716
+
677
717
# ## Project keys to specific paths and file permissions
678
718
679
719
You can project keys to specific paths and specific permissions on a per-file
@@ -860,6 +900,23 @@ A container using a ConfigMap as a [subPath](/docs/concepts/storage/volumes/#usi
860
900
{{< glossary_tooltip text=" static pods" term_id=" static-pod" > }}, because the
861
901
kubelet does not support this.
862
902
903
+ # # {{% heading "cleanup" %}}
904
+
905
+ Delete the ConfigMaps and Pods that you made:
906
+
907
+ ` ` ` bash
908
+ kubectl delete configmaps/game-config configmaps/game-config-2 configmaps/game-config-3 \
909
+ configmaps/game-config-env-file
910
+ kubectl delete pod dapi-test-pod --now
911
+
912
+ # You might already have removed the next set
913
+ kubectl delete configmaps/special-config configmaps/env-config
914
+ kubectl delete configmap -l ' game-config in (config-4,config-5)’
915
+ ```
916
+
917
+ If you created a directory `configure-pod-container` and no longer need it, you should remove that too,
918
+ or move it into the trash can / deleted files location.
919
+
863
920
864
921
## {{% heading "whatsnext" %}}
865
922
0 commit comments