Skip to content

Commit 24198cf

Browse files
committed
Add Edit secret step
1 parent a9aa488 commit 24198cf

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

content/en/docs/tasks/configmap-secret/managing-secret-using-kubectl.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,37 @@ accidentally, or from being stored in a terminal log.
153153
kubectl get secret db-user-pass -o jsonpath='{.data.password}' | base64 --decode
154154
```
155155

156+
## Edit a Secret {#edit-secret}
156157

157-
158-
In order to avoid storing a secret encoded value in your shell history, you can
159-
run the following command:
158+
You can edit an existing `Secret` object unless it is
159+
[immutable](/docs/concepts/configuration/secret/#secret-immutable). To edit a
160+
Secret, run the following command:
160161

161162
```shell
162-
kubectl get secret db-user-pass -o jsonpath='{.data.password}' | base64 --decode
163+
kubectl edit secrets <secret-name>
163164
```
164165

165-
The output shall be similar as above.
166+
This opens your default editor and allows you to update the base64 encoded
167+
Secret values in the `data` field, such as in the following example:
168+
169+
```yaml
170+
# Please edit the object below. Lines beginning with a '#' will be ignored,
171+
# and an empty file will abort the edit. If an error occurs while saving this file, it will be
172+
# reopened with the relevant failures.
173+
#
174+
apiVersion: v1
175+
data:
176+
password: UyFCXCpkJHpEc2I9
177+
username: YWRtaW4=
178+
kind: Secret
179+
metadata:
180+
creationTimestamp: "2022-06-28T17:44:13Z"
181+
name: db-user-pass
182+
namespace: default
183+
resourceVersion: "12708504"
184+
uid: 91becd59-78fa-4c85-823f-6d44436242ac
185+
type: Opaque
186+
```
166187

167188
## Clean Up
168189

0 commit comments

Comments
 (0)