Skip to content

Commit 98b840c

Browse files
author
Michael Burke
committed
edits
1 parent 61f0f95 commit 98b840c

4 files changed

+125
-74
lines changed

modules/nodes-pods-configmap-creating-from-directories.adoc

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,50 @@
11
// Module included in the following assemblies:
22
//
3-
//* authentication/configmaps.adoc
3+
//* nodes/pods/nodes-pods-configmap.adoc
44

55
:_content-type: PROCEDURE
66
[id="nodes-pods-configmap-creating-from-directories_{context}"]
77
= Creating a config map from a directory
88

9-
You can create a config map from a directory. This method allows you to use multiple files within a directory to create a config map.
9+
You can create a config map from a directory by using the `--from-file` flag. This method allows you to use multiple files within a directory to create a config map.
1010

11-
.Procedure
11+
Each file in the directory is used to populate a key in the config map, where the name of the key is the file name, and the value of the key is the content of the file.
1212

13-
The following example procedure outlines how to create a config map from a directory.
13+
For example, the following command creates a config map with the contents of the `example-files` directory:
1414

15-
. Start with a directory with some files that already contain the data with which you want to populate a config map:
16-
+
1715
[source,terminal]
1816
----
19-
$ ls example-files
17+
$ oc create configmap game-config --from-file=example-files/
2018
----
21-
+
19+
20+
View the keys in the config map:
21+
22+
[source,terminal]
23+
----
24+
$ oc describe configmaps game-config
25+
----
26+
2227
.Example output
2328
[source,terminal]
2429
----
25-
game.properties
26-
ui.properties
30+
Name: game-config
31+
Namespace: default
32+
Labels: <none>
33+
Annotations: <none>
34+
35+
Data
36+
37+
game.properties: 158 bytes
38+
ui.properties: 83 bytes
2739
----
40+
41+
You can see that the two keys in the map are created from the file names in the directory specified in the command. The content of those keys might be large, so the output of `oc describe` only shows the names of the keys and their sizes.
42+
43+
.Prerequisite
44+
45+
* You must have a directory with files that contain the data you want to populate a config map with.
46+
+
47+
The following procedure uses these example files: `game.properties` and `ui.properties`:
2848
+
2949
[source,terminal]
3050
----
@@ -57,40 +77,19 @@ allow.textmode=true
5777
how.nice.to.look=fairlyNice
5878
----
5979
60-
. Create a config map holding the content of each file in this directory by entering the following command:
80+
.Procedure
81+
82+
* Create a config map holding the content of each file in this directory by entering the following command:
6183
+
6284
[source,terminal]
6385
----
6486
$ oc create configmap game-config \
6587
--from-file=example-files/
6688
----
67-
+
68-
When the `--from-file` option points to a directory, each file directly in that directory is used to populate a key in the config map, where the name of the key is the file name, and the value of the key is the content of the file.
69-
+
70-
For example, the previous command creates the following config map:
71-
+
72-
[source,terminal]
73-
----
74-
$ oc describe configmaps game-config
75-
----
76-
+
77-
.Example output
78-
[source,terminal]
79-
----
80-
Name: game-config
81-
Namespace: default
82-
Labels: <none>
83-
Annotations: <none>
8489
85-
Data
90+
.Verification
8691

87-
game.properties: 158 bytes
88-
ui.properties: 83 bytes
89-
----
90-
+
91-
You can see that the two keys in the map are created from the file names in the directory specified in the command. Because the content of those keys might be large, the output of `oc describe` only shows the names of the keys and their sizes.
92-
+
93-
. Enter the `oc get` command for the object with the `-o` option to see the values of the keys:
92+
* Enter the `oc get` command for the object with the `-o` option to see the values of the keys:
9493
+
9594
[source,terminal]
9695
----

modules/nodes-pods-configmap-creating-from-files.adoc

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,79 @@
66
[id="nodes-pods-configmap-creating-from-files_{context}"]
77
= Creating a config map from a file
88

9-
You can create a config map from a file.
9+
You can create a config map from a file by using the `--from-file` flag. You can pass the `--from-file` option multiple times to the CLI.
1010

11-
.Procedure
11+
You can also specify the key to set in a config map for content imported from a file by passing a `key=value` expression to the `--from-file` option. For example:
1212

13-
The following example procedure outlines how to create a config map from a file.
13+
[source,terminal]
14+
----
15+
$ oc create configmap game-config-3 --from-file=game-special-key=example-files/game.properties
16+
----
1417

1518
[NOTE]
1619
====
1720
If you create a config map from a file, you can include files containing non-UTF8 data that are placed in this field without corrupting the non-UTF8 data. {product-title} detects binary files and transparently encodes the file as `MIME`. On the server, the `MIME` payload is decoded and stored without corrupting the data.
1821
====
1922

20-
You can pass the `--from-file` option multiple times to the CLI. The following example yields equivalent results to the creating from directories example.
23+
.Prerequisite
24+
25+
* You must have a directory with files that contain the data you want to populate a config map with.
26+
+
27+
The following procedure uses these example files: `game.properties` and `ui.properties`:
28+
+
29+
[source,terminal]
30+
----
31+
$ cat example-files/game.properties
32+
----
33+
+
34+
.Example output
35+
[source,terminal]
36+
----
37+
enemies=aliens
38+
lives=3
39+
enemies.cheat=true
40+
enemies.cheat.level=noGoodRotten
41+
secret.code.passphrase=UUDDLRLRBABAS
42+
secret.code.allowed=true
43+
secret.code.lives=30
44+
----
45+
+
46+
[source,terminal]
47+
----
48+
$ cat example-files/ui.properties
49+
----
50+
+
51+
.Example output
52+
[source,terminal]
53+
----
54+
color.good=purple
55+
color.bad=yellow
56+
allow.textmode=true
57+
how.nice.to.look=fairlyNice
58+
----
59+
60+
.Procedure
2161

22-
. Create a config map by specifying a specific file:
62+
* Create a config map by specifying a specific file:
2363
+
2464
[source,terminal]
2565
----
2666
$ oc create configmap game-config-2 \
2767
--from-file=example-files/game.properties \
2868
--from-file=example-files/ui.properties
2969
----
70+
71+
* Create a config map by specifying a key-value pair:
3072
+
31-
. Verify the results:
73+
[source,terminal]
74+
----
75+
$ oc create configmap game-config-3 \
76+
--from-file=game-special-key=example-files/game.properties
77+
----
78+
79+
.Verification
80+
81+
* Enter the `oc get` command for the object with the `-o` option to see the values of the keys from the file:
3282
+
3383
[source,terminal]
3484
----
@@ -63,17 +113,7 @@ metadata:
63113
uid: b4952dc3-d670-11e5-8cd0-68f728db1985
64114
----
65115
66-
You can specify the key to set in a config map for content imported from a file. This can be set by passing a `key=value` expression to the `--from-file` option. For example:
67-
68-
. Create a config map by specifying a key-value pair:
69-
+
70-
[source,terminal]
71-
----
72-
$ oc create configmap game-config-3 \
73-
--from-file=game-special-key=example-files/game.properties
74-
----
75-
76-
. Verify the results:
116+
* Enter the `oc get` command for the object with the `-o` option to see the values of the keys from the key-value pair:
77117
+
78118
[source,terminal]
79119
----

modules/nodes-pods-configmap-creating-from-literal-values.adoc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
You can supply literal values for a config map.
1010

11-
.Procedure
11+
The `--from-literal` option takes a `key=value` syntax, which allows literal values to be supplied directly on the command line.
1212

13-
The `--from-literal` option takes a `key=value` syntax that allows literal values to be supplied directly on the command line.
13+
.Procedure
1414

15-
. Create a config map by specifying a literal value:
15+
* Create a config map by specifying a literal value:
1616
+
1717
[source,terminal]
1818
----
@@ -21,7 +21,9 @@ $ oc create configmap special-config \
2121
--from-literal=special.type=charm
2222
----
2323
24-
. Verify the results:
24+
.Verification
25+
26+
* Enter the `oc get` command for the object with the `-o` option to see the values of the keys:
2527
+
2628
[source,terminal]
2729
----

modules/nodes-pods-priority-configuring.adoc

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,22 @@
66
[id="nodes-pods-priority-configuring_{context}"]
77
= Configuring priority and preemption
88

9-
You apply pod priority and preemption by creating a priority class object and associating pods to the priority using the
10-
`priorityClassName` in your `Pod` specs.
9+
You apply pod priority and preemption by creating a priority class object and associating pods to the priority by using the
10+
`priorityClassName` in your pod specs.
1111

12-
.Sample priority class object
12+
[NOTE]
13+
====
14+
You cannot add a priority class directly to an existing scheduled pod.
15+
====
16+
17+
.Procedure
18+
19+
To configure your cluster to use priority and preemption:
20+
21+
. Create one or more priority classes:
22+
23+
.. Create a YAML file similar to the following:
24+
+
1325
[source,yaml]
1426
----
1527
apiVersion: scheduling.k8s.io/v1
@@ -23,23 +35,21 @@ description: "This priority class should be used for XYZ service pods only." <5>
2335
----
2436
<1> The name of the priority class object.
2537
<2> The priority value of the object.
26-
<3> Optional field that indicates whether this priority class is preempting or non-preempting. The preemption policy defaults to `PreemptLowerPriority`, which allows pods of that priority class to preempt lower-priority pods. If the preemption policy is set to `Never`, pods in that priority class are non-preempting.
27-
<4> Optional field that indicates whether this priority class should be used for pods without a priority class name specified. This field is `false` by default. Only one priority class with `globalDefault` set to `true` can exist in the cluster. If there is no priority class with `globalDefault:true`, the priority of pods with no priority class name is zero. Adding a priority class with `globalDefault:true` affects only pods created after the priority class is added and does not change the priorities of existing pods.
28-
<5> Optional arbitrary text string that describes which pods developers should use with this priority class.
29-
30-
.Procedure
38+
<3> Optional. Specifies whether this priority class is preempting or non-preempting. The preemption policy defaults to `PreemptLowerPriority`, which allows pods of that priority class to preempt lower-priority pods. If the preemption policy is set to `Never`, pods in that priority class are non-preempting.
39+
<4> Optional. Specifies whether this priority class should be used for pods without a priority class name specified. This field is `false` by default. Only one priority class with `globalDefault` set to `true` can exist in the cluster. If there is no priority class with `globalDefault:true`, the priority of pods with no priority class name is zero. Adding a priority class with `globalDefault:true` affects only pods created after the priority class is added and does not change the priorities of existing pods.
40+
<5> Optional. Describes which pods developers should use with this priority class. Enter an arbitrary text string.
3141

32-
To configure your cluster to use priority and preemption:
33-
34-
. Create one or more priority classes:
35-
36-
.. Specify a name and value for the priority.
42+
.. Create the priority class:
43+
+
44+
[source,terminal]
45+
----
46+
$ oc create -f <file-name>.yaml
47+
----
3748

38-
.. Optionally specify the `globalDefault` field in the priority class and a description.
49+
. Create a pod spec to include the name of a priority class:
3950

40-
. Create a `Pod` spec or edit existing pods to include the name of a priority class, similar to the following:
51+
.. Create a YAML file similar to the following:
4152
+
42-
.Sample `Pod` spec with priority class name
4353
[source,yaml]
4454
----
4555
apiVersion: v1
@@ -57,7 +67,7 @@ spec:
5767
----
5868
<1> Specify the priority class to use with this pod.
5969

60-
. Create the pod:
70+
.. Create the pod:
6171
+
6272
[source,terminal]
6373
----

0 commit comments

Comments
 (0)