Skip to content
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

Feature request: Support reading secrets from terminal in kubectl #54200

Closed
tamalsaha opened this issue Oct 19, 2017 · 9 comments
Closed

Feature request: Support reading secrets from terminal in kubectl #54200

tamalsaha opened this issue Oct 19, 2017 · 9 comments
Labels
area/kubectl kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. sig/cli Categorizes an issue or PR as relevant to SIG CLI.

Comments

@tamalsaha
Copy link
Member

kubectl create secret command supports --from-literal and --from-file options. But neither options are convenient when creating secrets manually from terminal.

  • Using -- from-literal will keep the secret in shell history.
  • Using --from-file requires creating the file first and then deleting it, etc.

I would like to see a flag like --from-keys=k1,k2,k3. Given this flag is present, kubectl will ask user for input for each key and create a secret using that info. It can use something like https://github.com/howeyc/gopass to read the value without echo.

/kind feature
/sig cli

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. sig/cli Categorizes an issue or PR as relevant to SIG CLI. labels Oct 19, 2017
@php-coder
Copy link
Contributor

php-coder commented Oct 19, 2017

Because in Unix terminal is represented as file /dev/stdin, you can use the following command:

$ kubectl create secret generic foo --from-file=test=/dev/stdin
tada <-- this was manually typed in a terminal
secret "foo" created
$ kubectl get secret foo -o yaml | grep ^data: -A1
data:
  test: dGFkYQo=
$ echo -n dGFkYQo= | base64 -d
tada

@tamalsaha
Copy link
Member Author

Thanks @php-coder ! I guess this works in linux / mc. Windows users will be out of luck.

@tamalsaha
Copy link
Member Author

@php-coder , I just tried this in Ubuntu 16.04. How to I end the read process? I tried pressing Enter but the read did not close.

@php-coder
Copy link
Contributor

I tried pressing Enter but the read did not close.

Yes, I forgot to mention that you should use Ctrl+D to quit :)

@tamalsaha
Copy link
Member Author

tamalsaha commented Oct 19, 2017

:) It worked after ctrl + D. I even tried with multiple keys.

I think one issue still remains in that I don't know in what order the keys are read by kubectl. A common scenario is creating AWS credentials. If kubectl can prompt back the secret, that will make things bit nicer.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 6, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 6, 2018
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@sureshamk
Copy link

I use this handy method

kubectl get secrets <secretname> -o json | jq '.data | map_values(@base64d)'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubectl kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. sig/cli Categorizes an issue or PR as relevant to SIG CLI.
Projects
None yet
Development

No branches or pull requests

6 participants