KCL is an open-source constraint-based record & functional language mainly used in configuration and policy scenarios.
Learn MoreDownloadOriginated from programming languages such as Python and Golang, rich language features, power IDEs and tools.
Schema-centric configuration types and modular abstraction with logic and policy based on Config, Schema, Lambda, Rule.
Configuration stability built on static type system, strong immutablity , and constraints.
High scalability through automatic merge mechanism of isolated config blocks with multiple strategies.
High performance and gradient automation scheme of CRUD APIs, multilingual SDKs, language plugins for GitOps.
Native support API ecological specifications such as OpenAPI, Kubernetes CRD and KRM spec.
With configs, models, functions and rules
import konfig.models.kube.frontendserver: frontend.Server {image = "nginx"}
-- Configimport konfig.models.kube.frontendserver: 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: strreplicas: int = option("replicas") or 1labels?: {str:str}
-- Schemaschema 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: strreplicas: int = option("replicas") or 1labels?: {str:str}
import konfig.models.kube.frontendgenLocalityLabels = 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")}
-- Lambdaimport konfig.models.kube.frontendgenLocalityLabels = 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 regexrule 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()
-- Ruleimport regexrule 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()
IDEs, SDKs, Sharing, Formatting, Testing, Documents