An Interest In:
Web News this Week
- April 20, 2024
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
July 12, 2020 06:20 pm GMT
Original Link: https://dev.to/focusedlabs/editing-kubernetes-secrets-inline-44f7
Editing Kubernetes Secrets Inline
We work a lot with Kubernetes and when you're working with Secrets
it can be a total pain to edit them. A standard workflow can be something like.
# Grab the existing secretkubectl get secret some-secret -o yaml > some-secret.yaml# Grab the existing secretkubectl get secret some-secret \ -o jsonpath='{ .data.secret }' \ | base64 -D > thesecert.txt# Edit the secretvim thesecret.txt# Grab the new secret and put it into the secret file# and apply it to the clustercat thesecret.txt | base64 | pbcopyvim some-secret.yaml # paste in your b64 encoded secretkubectl apply -f some-secret.yaml
That's not a great user experience and what if you wanted to use kubectl edit
?
There's a bit of vim foo you can use to edit the secret in line.
kubectl edit secret some-secret# navigate to the base64 encoded secret# place your cursor on the space between the ":"# and the first character of the secret# hit `r <enter>` this replaces the space with a # new line# move your cursor down one line to the secret# in the command prompt `:. ! base64 -D`# Edit your secret# in the command prompt `:. ! base64`# Join the lines by moving back up the secret key# and hitting `J`# Then write quit `:wq`# you should see this as output# `secret/some-secret edited`
And if you want to edit a multiline secret say one that was created from a file. Rather than base64
encoding the current line using :.
you can use a range of line numbers :13,84 ! base64
and you will encode all those lines together inclusive of line 84.
Original Link: https://dev.to/focusedlabs/editing-kubernetes-secrets-inline-44f7
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To