CLI tool to manage Kubernetes Secrets easily
Kubernetes 1.18 or above
Formula is available at dtan4/homebrew-dtan4.
brew tap dtan4/tools
brew install k8sec
Precompiled binaries for Windows, OS X, Linux are available at Releases.
go get -d github.com/dtan4/k8sec
cd $GOPATH/src/github.com/dtan4/k8sec
make install
Docker image is no longer provided officially.
If you'd like to run k8sec in Docker image, see Dockerfile
and build image by yourself.
docker build -t k8sec .
Option | Description | Required | Default |
---|---|---|---|
--context=CONTEXT |
Kubernetes context | ||
--kubeconfig=KUBECONFIG |
Path of kubeconfig | ~/.kube/config |
|
-n , --namespace=NAMESPACE |
Kubernetes namespace | default |
|
-h , -help |
Print command line usage |
List secrets
$ k8sec list [--base64] [NAME]
# Example
$ k8sec list rails
NAME TYPE KEY VALUE
rails Opaque database-url "postgres://example.com:5432/dbname"
# Show values as base64-encoded string
$ k8sec list --base64 rails
NAME TYPE KEY VALUE
rails Opaque database-url cG9zdGdyZXM6Ly9leGFtcGxlLmNvbTo1NDMyL2RibmFtZQ==
Set secrets
$ k8sec set [--base64] NAME KEY1=VALUE1 [KEY2=VALUE2 ...]
$ k8sec set rails rails-env=production
rails
# Set base64-encoded value
$ echo -n dtan4 | base64
ZHRhbjQ=
$ k8sec set --base64 rails foo=ZHRhbjQ=
rails
# Result
$ k8sec list rails
NAME TYPE KEY VALUE
rails Opaque database-url "postgres://example.com:5432/dbname"
rails Opaque foo "dtan4"
Unset secrets
$ k8sec unset NAME KEY1 KEY2...
# Example
$ k8sec unset rails rails-env
Load secrets from dotenv (key=value) format text
$ k8sec load [-f FILENAME] NAME
# Example
$ cat .env
database-url="postgres://example.com:5432/dbname"
$ k8sec load -f .env rails
# Load from stdin
$ cat .env | k8sec load rails
Dump secrets as dotenv (key=value) format
$ k8sec dump [-f FILENAME] [--noquotes] [NAME]
# Example
$ k8sec dump rails
database-url="postgres://example.com:5432/dbname"
# Save as .env
$ k8sec dump -f .env rails
$ cat .env
database-url="postgres://example.com:5432/dbname"
# Save as .env without qoutes
$ k8sec dump -f .env --noquotes rails
$ cat .env
database-url=postgres://example.com:5432/dbname
- Fork (https://github.com/dtan4/k8sec/fork)
- Create a feature branch
- Commit your changes
- Rebase your local changes against the master branch
- Run test suite with the
go test ./...
command and confirm that it passes - Run
gofmt -s
- Create a new Pull Request