-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify secret without worrying about base64 encode/decode #1017
Comments
@tcaenen Unless I am mistaken, you don't a plugin for this as you can just use stringData since it's just an encoding. Might as well let k8s take care of base64ing your secrets. |
Why not use the excellent I configured this by adding the following to my plugin:
edit-secret:
shortCut: Ctrl-X
confirm: false
description: "Edit Decoded Secret"
scopes:
- secrets
command: kubectl
background: false
args:
- modify-secret
- --namespace
- $NAMESPACE
- --context
- $CONTEXT
- $NAME Now I can edit secrets using this plugin with I had a brief look at the code for editing secrets and as suspected; @derailed is just calling |
For others trying out @fernferret's solution: You need to install krew and the kubectl-modify-secret plugin found here |
It works! Thanks @fernferret & @jontro |
|
it would be great if k9s could do this without a plugin. At least for me above did not work. Although |
Seconding this. It's very useful that k9s can view a secret in decoded form. The existing functionality to edit a secret in k9s is inconvenient (because you're editing the base64 encoding rather than the plaintext). I don't see any reason why a third-party kubectl plugin should be necessitated? This enhancement might also be a good first issue, in that it seems like a moderately straightforward and self-contained feature request (to combine the existing functionality of the "decode" and "edit" functions, for example by re-encoding the data before dispatching). |
Step 2 is helpful, step 3 will ruin all your other apps, step 4 specifies incorrect filename and wrong content. Please see here how to properly organize the file. |
Minor update; k9s seems to have changed the desired location/extension of the plugins file and the format ever so slightly. # ~/.config/k9s/plugins.yaml
plugins:
edit-secret:
# Setup:
# brew install krew
# kubectl krew install modify-secret
# echo "export XDG_CONFIG_HOME=~/.config" >> ~/.zshrc # this may or may not be required now
# See also:
# https://github.com/derailed/k9s/issues/1017#issuecomment-1328330026
shortCut: Ctrl-X
confirm: false
description: "Edit Decoded Secret"
scopes:
- secrets
command: kubectl
background: false
args:
- modify-secret
- --namespace
- $NAMESPACE
- --context
- $CONTEXT
- $NAME I still think this would be an amazing thing to have built-in to k9s. It's been extremely useful |
I am also looking for a simple solution to edit secret without any plugin. This looks like a missed opportunity to make dev life simple |
This would be a really nice feature and the lack thereof is the only reason I still ocasionally use the kubernetes-dashboard. |
+1 This would make the tool easier to use, will use the plugin for the meantime but I can see this being a thing that stops people switching from Lens etc. |
Hello, Here's a plugin that doesn't require installing https://github.com/rajatjindal/kubectl-modify-secret, it does require you to have jq installed though. Another thing to note is that unfortunately the plugins:
edit-secret:
shortCut: Ctrl-X
confirm: false
description: Edit Decoded Secret
scopes:
- secrets
command: sh
background: false
args:
- -c
- >-
tempfile=$(mktemp);
secret=$(kubectl get secrets --context $CONTEXT --namespace $NAMESPACE $NAME -o json);
printf '%s\n' $secret | jq '.data | map_values(@base64d)' > $tempfile;
vim $tempfile;
secret_data=$(cat $tempfile | jq -c '. | map_values(@base64)');
rm $tempfile;
printf '%s\n' $secret | jq -r --argjson secret_data "$secret_data" '.data = $secret_data' | kubectl apply -f -; To install it, first check where your plugin file is supposed to live (it changes depending on your os) k9s info
____ __.________
| |/ _/ __ \______
| < \____ / ___/
| | \ / /\___ \
|____|__ \ /____//____ >
\/ \/
Version: vX.Y.Z
Config: /Users/fernand/.config/k9s/config.yaml
Logs: /Users/fernand/.local/state/k9s/k9s.log
Dumps dir: /Users/fernand/.local/state/k9s/screen-dumps
Benchmarks dir: /Users/fernand/.local/state/k9s/benchmarks
Skins dir: /Users/fernand/.local/share/k9s/skins
Contexts dir: /Users/fernand/.local/share/k9s/clusters
Custom views file: /Users/fernand/.local/share/k9s/views.yaml
Plugins file: /Users/fernand/.local/share/k9s/plugins.yaml
Hotkeys file: /Users/fernand/.local/share/k9s/hotkeys.yaml
Alias file: /Users/fernand/.local/share/k9s/aliases.yaml Then copy this file to the path indicated by the line |
There's already a kubectl plugin that works quite well to do that : https://github.com/rajatjindal/kubectl-modify-secret
It would be an awesome feature to add to k9s.
Maybe using a new shortcut like ctrl-x ?
The text was updated successfully, but these errors were encountered: