kubectl-envsecret is a Kubernetes plugin designed to simplify the creation of
Kubernetes secrets from .env files, including support for multiline
environment variables. This tool streamlines the management of secrets, making
it easier to handle configurations that include complex multiline values.
- Create Kubernetes secrets from
.envfiles. - Support for multiline environment variables.
- Easy integration with
kubectlas a plugin.
To install kubectl-envsecret, you need to have Go installed on your machine.
You can then use the following command to install the plugin:
go install github.com/ogticrd/kubectl-envsecret@latestThe primary command provided by kubectl-envsecret is create, which reads a
.env file and creates a corresponding Kubernetes secret.
kubectl envsecret create --from-env-file <path-to-env-file> --from-env-file <path-to-other-files>--from-env-file: Specifies the path(s) to the.envfile. This option can be used multiple times to specify multiple.envfiles.
kubectl envsecret create --from-env-file /path/to/.envkubectl envsecret create --from-env-file /path/to/.env --from-env-file /another/path/.env- Go
- Cobra CLI
First you need is cloning the project
git clone https://github.com/ogticrd/kubectl-envsecret.git
cd kubectl-envsecretTo build the project, clone the repository and run:
go build -o kubectl-envsecret main.gomake buildgo run main.goNote
Just run ./kubectl-envsecret if you already built it.
make run
# For passing args and flags
make run CMD="create" ARGS="secret-name" FLAGS="--from-env-file /path/to/secret --namespace default"To run the tests, use the following command:
go test ./...make test.
├── LICENSE
├── Makefile
├── README.md
├── cmd
│ ├── create.go
│ └── root.go
├── go.mod
├── go.sum
├── internal
│ ├── k8sapi
│ │ └── k8s.go
│ ├── parser
│ │ └── env.go
│ └── utils
│ └── utils.go
└── main.go
- cmd: Contains the CLI command definitions.
- internal/k8sapi: Contains a wrapper of the usage of Kubernetes API to manage secrets.
- internal/parser: Contains functions to parse
.envfiles. - internal/utils: Contains utility functions used by the commands.
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
This project uses the following libraries:
- Cobra CLI for creating the command-line interface.
- Kubernetes CLI Runtime for Kubernetes API interactions.