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
.env
files. - Support for multiline environment variables.
- Easy integration with
kubectl
as 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@latest
The 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.env
file. This option can be used multiple times to specify multiple.env
files.
kubectl envsecret create --from-env-file /path/to/.env
kubectl 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-envsecret
To build the project, clone the repository and run:
go build -o kubectl-envsecret main.go
make build
go run main.go
Note
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
.env
files. - 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.