简单易用
源于 Python、Go 等语言,丰富的语言特性,IDE 插件和工具链
快速建模
以 Schema 为中心的配置类型及模块化抽象,基于 Config、Schema、Lambda、Rule 的逻辑和策略编写
可靠稳定
依赖静态类型系统、约束和自定义规则的配置稳定性
强可扩展
通过独立配置块自动合并机制保证配置编写的高可扩展性
易自动化
CRUD APIs,多语言 SDK,语言插件 构成的梯度自动化方案
API 亲和
原生支持 OpenAPI、 Kubernetes CRD, Kubernetes YAML,KRM 等 API 生态规范
以更现代化的编程方式管理配置和策略
配置,模型,函数和规则
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()
使用工具提升体验
IDE 插件,包管理,格式化,测试和文档工具