Merge pull request #35384 from shannonxtreme/add-edit-secret-file

Add Edit Secret step to Managing Secrets Using a Configuration File
pull/37326/head
Kubernetes Prow Robot 2022-10-15 12:19:06 -07:00 committed by GitHub
commit b1f8531498
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 55 additions and 0 deletions

View File

@ -170,6 +170,61 @@ type: Opaque
`YWRtaW5pc3RyYXRvcg==` decodes to `administrator`.
## Edit a Secret {#edit-secret}
To edit the data in the Secret you created using a manifest, modify the `data`
or `stringData` field in your manifest and apply the file to your
cluster. You can edit an existing `Secret` object unless it is
[immutable](/docs/concepts/configuration/secret/#secret-immutable).
For example, if you want to change the password from the previous example to
`birdsarentreal`, do the following:
1. Encode the new password string:
```shell
echo -n 'birdsarentreal' | base64
```
The output is similar to:
```
YmlyZHNhcmVudHJlYWw=
```
1. Update the `data` field with your new password string:
```yaml
apiVersion: v1
kind: Secret
metadata:
name: mysecret
type: Opaque
data:
username: YWRtaW4=
password: YmlyZHNhcmVudHJlYWw=
```
1. Apply the manifest to your cluster:
```shell
kubectl apply -f ./secret.yaml
```
The output is similar to:
```
secret/mysecret configured
```
Kubernetes updates the existing `Secret` object. In detail, the `kubectl` tool
notices that there is an existing `Secret` object with the same name. `kubectl`
fetches the existing object, plans changes to it, and submits the changed
`Secret` object to your cluster control plane.
If you specified `kubectl apply --server-side` instead, `kubectl` uses
[Server Side Apply](/docs/reference/using-api/server-side-apply/) instead.
## Clean up
To delete the Secret you have created: