KCL is a constraint-based record & functional domain language. Full documents of KCL can be found here.
This project is a kubectl
plugin to generate, mutate and validate Kubernetes manifests using the KCL programming language.
Use this as a kubectl
plugin.
Add to krew
index and install with:
kubectl krew index add kubectl-kcl https://github.com/kcl-lang/kubectl-kcl
kubectl krew install kubectl-kcl/kcl
Download the binary from GitHub releases, then copy the kubectl-kcl
binary to your PATH
. If not, you can also use the binary standalone.
kubectl kcl run -f ./examples/kcl-run.yaml
- GoLang 1.23+
git clone https://github.com/kcl-lang/kubectl-kcl.git
cd kubectl-kcl
go run main.go
go test ./...
go run main.go run -f ./examples/kcl-run.yaml
Here's what you can do in the KCL script:
- Read resources from
option("resource_list")
. Theoption("resource_list")
complies with the KRM Functions Specification. You can read the input resources fromoption("items")
and thefunctionConfig
fromoption("functionConfig")
. - Return a KRM list for output resources.
- Return an error using
assert {condition}, {error_message}
. - Read the PATH variables. e.g.
option("PATH")
. - Read the environment variables. e.g.
option("env")
.
Full documents of KCL can be found here.