@@ -170,6 +170,61 @@ type: Opaque
170
170
171
171
` YWRtaW5pc3RyYXRvcg==` decodes to `administrator`.
172
172
173
+ # # Edit a Secret {#edit-secret}
174
+
175
+ To edit the data in the Secret you created using a manifest, modify the `data`
176
+ or `stringData` field in your manifest and apply the file to your
177
+ cluster. You can edit an existing `Secret` object unless it is
178
+ [immutable](/docs/concepts/configuration/secret/#secret-immutable).
179
+
180
+ For example, if you want to change the password from the previous example to
181
+ `birdsarentreal`, do the following :
182
+
183
+ 1. Encode the new password string :
184
+
185
+ ` ` ` shell
186
+ echo -n 'birdsarentreal' | base64
187
+ ` ` `
188
+
189
+ The output is similar to :
190
+
191
+ ```
192
+ YmlyZHNhcmVudHJlYWw=
193
+ ```
194
+
195
+ 1. Update the `data` field with your new password string:
196
+
197
+ ```yaml
198
+ apiVersion: v1
199
+ kind: Secret
200
+ metadata:
201
+ name: mysecret
202
+ type: Opaque
203
+ data:
204
+ username: YWRtaW4=
205
+ password: YmlyZHNhcmVudHJlYWw=
206
+ ```
207
+
208
+ 1 . Apply the manifest to your cluster:
209
+
210
+ ``` shell
211
+ kubectl apply -f ./secret.yaml
212
+ ```
213
+
214
+ The output is similar to:
215
+
216
+ ```
217
+ secret/mysecret configured
218
+ ```
219
+
220
+ Kubernetes updates the existing ` Secret ` object. In detail, the ` kubectl ` tool
221
+ notices that there is an existing ` Secret ` object with the same name. ` kubectl `
222
+ fetches the existing object, plans changes to it, and submits the changed
223
+ ` Secret ` object to your cluster control plane.
224
+
225
+ If you specified ` kubectl apply --server-side ` instead, ` kubectl ` uses
226
+ [ Server Side Apply] ( /docs/reference/using-api/server-side-apply/ ) instead.
227
+
173
228
## Clean up
174
229
175
230
To delete the Secret you have created:
0 commit comments