https://www.kcl-lang.io/ Skip to main content Give us a star [?] - If you are using KCL or think it is an interesting project, we would love a star and record on Github and Record Issue KCL LogoKCL Logo Getting StartedReferenceToolsModulesPlaygroundExamplesCommunityBlog 0.9 * Next * 0.9 * 0.8 * 0.7 * 0.6 * 0.5 * 0.4 English * English * Jian Ti Zhong Wen * Help Us Translate Mutation, Validation, Abstraction, Automation Production-Ready KCL is an open-source constraint-based record & functional language mainly used in configuration and policy scenarios. Learn MoreDownload Easy-to-Use Originated from programming languages such as Python and Golang, rich language features, power IDEs and tools. Quick Modeling Schema-centric configuration types and modular abstraction with logic and policy based on Config, Schema, Lambda, Rule. Stability Configuration stability built on static type system, strong immutablity , and constraints. Scalability High scalability through automatic merge mechanism of isolated config blocks with multiple strategies. Fast Automation High performance and gradient automation scheme of CRUD APIs, multilingual SDKs, language plugins for GitOps. API Affinity Native support API ecological specifications such as OpenAPI, Kubernetes CRD and KRM spec. Codify and Manage Your Modern Configuration and Policy With configs, models, functions and rules import konfig.models.kube.frontend server: frontend.Server { image = "nginx" } -- Config import konfig.models.kube.frontend server: frontend.Server { image = "nginx" } schema Server: """Server is the abstraction of Deployment and StatefulSet. image: str, default is Undefined, required. Image name. More info: https://kubernetes.io/docs/concepts/containers/images. replicas: int, default is 1, required. Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1. labels: {str:str}, default is Undefined, optional. Labels is a map of string keys and values that can be used to organize and categorize (scope and select) objects. """ image: str replicas: int = option("replicas") or 1 labels?: {str:str} -- Schema schema Server: """Server is the abstraction of Deployment and StatefulSet. image: str, default is Undefined, required. Image name. More info: https://kubernetes.io/docs/concepts/containers/images. replicas: int, default is 1, required. Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1. labels: {str:str}, default is Undefined, optional. Labels is a map of string keys and values that can be used to organize and categorize (scope and select) objects. """ image: str replicas: int = option("replicas") or 1 labels?: {str:str} import konfig.models.kube.frontend genLocalityLabels = lambda cluster: str, app: str -> {str:str} { { "cluster.x-k8s.io/cluster-name" = cluster "app.kubernetes.io/name" = app } } server: frontend.Server { labels: genLocalityLabels("my-cluster", "nginx") } -- Lambda import konfig.models.kube.frontend genLocalityLabels = lambda cluster: str, app: str -> {str:str} { { "cluster.x-k8s.io/cluster-name" = cluster "app.kubernetes.io/name" = app } } server: frontend.Server { labels: genLocalityLabels("my-cluster", "nginx") } import regex rule ServerRule for Server: 1 <= replicas < 20, "replica should be in range [1, 20)" regex.match(image, r"^([a-z0-9.:]+).([a-z]+):([a-z0-9]+)/([a-z0-9.]+)/([a-z0-9-_.:]+)$"), "image name should satisfy the `REPOSITORY:TAG` form" ServerRule() -- Rule import regex rule ServerRule for Server: 1 <= replicas < 20, "replica should be in range [1, 20)" regex.match(image, r"^([a-z0-9.:]+).([a-z]+):([a-z0-9]+)/([a-z0-9.]+)/([a-z0-9-_.:]+)$"), "image name should satisfy the `REPOSITORY:TAG` form" ServerRule() Config Start your cloud-native journey with scalable config Schema Abstract your schema-centric model with static typing Lambda Define and reuse your config and logic through small function fragments Rule Define your environmental rules to ensure consistency and stability Tools for Experience IDEs, SDKs, Sharing, Formatting, Testing, Documents Tool image Integrate with Your Favorite Projects Kubernetes Kustomize Helm Helmfile KPT Argo Flux Ansible KusionStack KubeVela CrossPlane Terraform Trusted By Ant Group Youzan Huawei Kyligence We are a Cloud Native Computing Foundation sandbox project CNCF themed image Subscribe to Newsletter [ ] [ ]Subscribe Document * Introduction * Guides * Tutorial * FAQ Resource * Github * Blog * Community More * KusionStack (c) KCL Authors 2024 | Documentation Distributed under CC-BY-4.0 (c) 2024 The Linux Foundation. All rights reserved. The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.