
Company News
Andrew Becherer Joins Socket as Chief Information Security Officer
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.
kcl-lang.io/kcl-operator
Advanced tools
KCL Operator provides cluster integration, allowing you to use Access Webhook to generate, mutate, or validate resources based on KCL configuration when apply resources to the cluster. Webhook will capture creation, application, and editing operations, and execute KCLRun on the configuration associated with each operation, and the KCL programming language can be used to
PodTemplate.
Run make help to get the help.
make deploy
Use the following command to watch and wait for the pod status is Running.
kubectl get po
kubectl apply -f- << EOF
apiVersion: krm.kcl.dev/v1alpha1
kind: KCLRun
metadata:
name: set-annotation
spec:
params:
annotations:
managed-by: kcl-operator
source: oci://ghcr.io/kcl-lang/set-annotation
EOF
kubectl apply -f- << EOF
apiVersion: v1
kind: Pod
metadata:
name: nginx
annotations:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
EOF
kubectl get po nginx -o yaml | grep kcl-operator
The output is
managed-by: kcl-operator
We can find the annotation managed-by=kcl-operator is added on the pod.
Here's what you can do in the KCL script:
option("resource_list"). The option("resource_list") complies with the KRM Functions Specification. You can read the input resources from option("items") and the params from option("params").assert {condition}, {error_message}.print(variable) and it will be output to the stdout of the pod.option("PATH").option("env").A KRM YAML list means that each document must have an apiVersion, kind through the items field or a single YAML output.
items fieldapiVersion: krm.kcl.dev/v1alpha1
kind: KCLRun
metadata:
name: basic
spec:
source: |
items = [{
apiVersion: "v1"
kind: "Foo"
metadata.name = "foo"
}, {
apiVersion: "v1"
kind: "Bar"
metadata.name = "bar"
}]
apiVersion: krm.kcl.dev/v1alpha1
kind: KCLRun
metadata:
name: basic
spec:
source: |
{
apiVersion: "v1"
kind: "Foo"
metadata.name = "foo"
}
You can directly use KCL standard libraries such as regex.match, math.log.
See here to study more features of KCL.
See here for more examples.
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.

Company News
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.

Security News
npm confirmed a tooling bug incorrectly marked several one-character packages as security holders and said it was working on a rollback.