Skip to content

Latest commit

 

History

History
87 lines (65 loc) · 3.47 KB

README.md

File metadata and controls

87 lines (65 loc) · 3.47 KB

Helmfile KCL Plugin

Go Report Card GoDoc License FOSSA Status

KCL is a constraint-based record & functional domain language. Full documents of KCL can be found here.

You can use the helmfile-kcl plugin to

  • Edit the helm charts in a hook way to separate data and logic for the Kubernetes manifests management.
  • For multi-environment and multi-tenant scenarios, you can maintain these configurations gracefully rather than simply copy and paste.
  • Validate all KRM resources using the KCL schema.

Install

Prerequisites

Quick Start

cd examples/hello-world && helmfile apply

The content of helmfile.yaml looks like this:

repositories:
- name: prometheus-community
  url: https://prometheus-community.github.io/helm-charts

releases:
- name: prom-norbac-ubuntu
  namespace: prometheus
  chart: prometheus-community/prometheus
  set:
  - name: rbac.create
    value: false
  transformers:
  # Use KRM KCL Plugin to mutate or validate Kubernetes manifests.
  - apiVersion: krm.kcl.dev/v1alpha1
    kind: KCLRun
    metadata:
      name: "set-annotation"
      annotations:
        config.kubernetes.io/function: |
          container:
            image: docker.io/kcllang/kustomize-kcl:v0.1.2
    spec:
      params:
        annotations:
          config.kubernetes.io/local-config: "true"
      source: oci://ghcr.io/kcl-lang/set-annotation

Guides for Developing KCL

Here's what you can do in the KCL script:

  • Read resources from option("resource_list"). The option("resource_list") complies with the KRM Functions Specification. You can read the input resources from option("resource_list")["items"] and the functionConfig from option("resource_list")["functionConfig"].
  • Return a KPM list for output resources.
  • Return an error using assert {condition}, {error_message}.
  • Read the environment variables. e.g. option("PATH") (Not yet implemented).
  • Read the OpenAPI schema. e.g. option("open_api")["definitions"]["io.k8s.api.apps.v1.Deployment"] (Not yet implemented).

Full documents of KCL can be found here.

Examples

See here for more examples.

Thanks

License

FOSSA Status