@@ -26,29 +26,30 @@ The keys of `data` and `stringData` must consist of alphanumeric characters,
26
26
27
27
The following example stores two strings in a Secret using the ` data ` field.
28
28
29
- Convert the strings to base64 as follows :
29
+ Convert the strings to base64:
30
30
31
31
``` shell
32
32
echo -n ' admin' | base64
33
- ```
34
-
35
- The output is similar to:
36
-
37
- ```
38
- YWRtaW4=
39
- ```
40
-
41
- ``` shell
42
33
echo -n ' 1f2d1e2e67df' | base64
43
34
```
44
35
36
+ {{< note >}}
37
+ The serialized JSON and YAML values of Secret data are encoded as base64
38
+ strings. Newlines are not valid within these strings and must be omitted. When
39
+ using the ` base64 ` utility on Darwin/macOS, users should avoid using the ` -b `
40
+ option to split long lines. Conversely, Linux users * should* add the option
41
+ ` -w 0 ` to ` base64 ` commands or the pipeline ` base64 | tr -d '\n' ` if the ` -w `
42
+ option is not available.
43
+ {{< /note >}}
44
+
45
45
The output is similar to:
46
46
47
47
```
48
+ YWRtaW4=
48
49
MWYyZDFlMmU2N2Rm
49
50
```
50
51
51
- Write a Secret config file that looks like this :
52
+ Create the configuration file:
52
53
53
54
``` yaml
54
55
apiVersion : v1
64
65
Note that the name of a Secret object must be a valid
65
66
[DNS subdomain name](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
66
67
67
- {{< note >}}
68
- The serialized JSON and YAML values of Secret data are encoded as base64
69
- strings. Newlines are not valid within these strings and must be omitted. When
70
- using the ` base64` utility on Darwin/macOS, users should avoid using the `-b`
71
- option to split long lines. Conversely, Linux users *should* add the option
72
- ` -w 0` to `base64` commands or the pipeline `base64 | tr -d '\n'` if the `-w`
73
- option is not available.
74
- {{< /note >}}
75
-
76
68
For certain scenarios, you may wish to use the ` stringData` field instead. This
77
69
field allows you to put a non-base64 encoded string directly into the Secret,
78
70
and the string will be encoded for you when the Secret is created or updated.
@@ -104,9 +96,7 @@ stringData:
104
96
password: <password>
105
97
` ` `
106
98
107
- # # Create the Secret object
108
-
109
- Now create the Secret using [`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands#apply):
99
+ Create the Secret using [`kubectl apply`](/docs/reference/generated/kubectl/kubectl-commands#apply):
110
100
111
101
` ` ` shell
112
102
kubectl apply -f ./secret.yaml
0 commit comments