-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add 2023-09-06-biweekly-newsletter blogs
- Loading branch information
Showing
2 changed files
with
349 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
--- | ||
slug: 2023-09-06-biweekly-newsletter | ||
title: KCL Biweekly Newsletter (2023 08.24 - 09.06) | Kubernetes Operator, IDE Extensions and v0.5.6 are out! | ||
authors: | ||
name: KCL Team | ||
title: KCL Team | ||
tags: [KCL, Biweekly-Newsletter] | ||
--- | ||
|
||
![](/img/biweekly-newsletter.png) | ||
|
||
[KCL](https://github.com/kcl-lang) is an open-source, constraint-based record and functional language that enhances the writing of complex configurations, including those for cloud-native scenarios. With its advanced programming language technology and practices, KCL is dedicated to promoting better modularity, scalability, and stability for configurations. It enables simpler logic writing and offers ease of automation APIs and integration with homegrown systems. | ||
|
||
This section will update the KCL language community's latest developments every two weeks, including features, website updates, and the latest community news, helping everyone better understand the KCL community! | ||
|
||
***KCL Website: [https://kcl-lang.io](https://kcl-lang.io)*** | ||
|
||
## Overview | ||
|
||
Thank you to all contributors for their outstanding work over the past two weeks (08.10-08.23 2023). Here is an overview of the key content: | ||
|
||
**🔧 Language and Toolchain Updates** | ||
|
||
- **KCL Import Tool Updates** - Supports exporting JSON/YAML data to KCL configuration. | ||
- **KCL IDE Updates** - Supports right-click formatting ability, formatting individual files or parts of KCL code. | ||
- **KCL Documentation Tool Updates** - Exported documents support HTML escape. | ||
- **KCL Package Management Tool KPM Updates** - `kpm run` command execution and error message optimization, supports running KCL packages located in local paths. | ||
- **KCL Language Updates** - Optimized system package type check error messages and unified error message codes. | ||
|
||
**📰 Official Website and Use Case Updates** | ||
|
||
- KCL website adds v0.5.6 documentation version. | ||
- Publishing KCL packages to docker.io or ghcr.io registries using Github Actions Example: [https://github.com/kcl-lang/kpm/blob/main/docs/push_by_github_action.md](https://github.com/kcl-lang/kpm/blob/main/docs/push_by_github_action.md) | ||
- KCL Operator example: [https://kcl-lang.io/docs/user_docs/guides/working-with-k8s/mutate-manifests/kcl-operator](https://kcl-lang.io/docs/user_docs/guides/working-with-k8s/mutate-manifests/kcl-operator) | ||
|
||
## Special Thanks | ||
|
||
The following are listed in no particular order: | ||
|
||
+ Thanks to @jakezhu9 for the contribution of converting JSON and YAML configuration data to KCL configuration in the KCL Import Tool 🙌 [https://github.com/kcl-lang/kcl-go/pull/141](https://github.com/kcl-lang/kcl-go/pull/141) | ||
+ Thanks to @xxmao123 and @starkers for their contributions to the KCL NeoVim and Idea IDE extensions 🙌 [https://github.com/kcl-lang/intellij-kcl/pull/12](https://github.com/kcl-lang/intellij-kcl/pull/12) | ||
+ Thanks to @kolloch, @prahaladramji, and others for their valuable feedback and discussions during the use of KCL in the past two weeks 🙌 | ||
|
||
**Congratulations @jakezhu9 for becoming a KCL community Maintainer 🎉** | ||
|
||
## Featured Updates | ||
|
||
### KCL Operator | ||
|
||
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](https://github.com/kcl-lang/krm-kcl) on the configuration associated with each operation, and the KCL programming language can be used to | ||
|
||
+ Add labels or annotations based on a condition. | ||
+ Inject a sidecar container in all KRM resources that contain a `PodTemplate`. | ||
+ Validating all KRM resources using KCL Schema, such as constraints on starting containers only in a root mode. | ||
+ Generating KRM resources using an abstract model or combining and using different KRM APIs. | ||
|
||
With KCL Operator, you can automate resource configuration management and security validation in a Kubernetes cluster using lightweight KCL code, without the need to develop a webhook server to dynamically mutate and validate configurations at runtime. | ||
|
||
Furthermore, leveraging KCL's modeling and abstraction capabilities, we can define functionality abstractions/compositions for different resource APIs and expose them in the form of KCL Schema. We can further generate OpenAPI Schema definitions from KCL Schema for other clients in the cluster to use, without manually maintaining complex OpenAPI Schema definitions for API abstractions/compositions. Here is an example of using KCL Operator to modify resource annotations: | ||
|
||
#### 0. Prerequisites | ||
|
||
Prepare a Kubernetes cluster like `k3d` the kubectl tool. | ||
|
||
#### 1. Install KCL Operator | ||
|
||
```shell | ||
kubectl apply -f https://raw.githubusercontent.com/kcl-lang/kcl-operator/main/config/all.yaml | ||
``` | ||
|
||
Use the following command to observe and wait for the pod status to be `Running`. | ||
|
||
```shell | ||
kubectl get po | ||
``` | ||
|
||
#### 2. Deploy KCL Annotation Setting Model | ||
|
||
```shell | ||
kubectl apply -f- << EOF | ||
apiVersion: krm.kcl.dev/v1alpha1 | ||
kind: KCLRun | ||
metadata: | ||
name: set-annotation | ||
spec: | ||
# Set dynamic parameters required for the annotation modification model, here we can add the labels we want to modify/add | ||
params: | ||
annotations: | ||
managed-by: kcl-operator | ||
# Reference the annotation modification model on OCI | ||
source: oci://ghcr.io/kcl-lang/set-annotation | ||
EOF | ||
``` | ||
|
||
#### 3. Deploy a Pod to Verify the Model Result | ||
|
||
Execute the following command to deploy a `Pod` resource: | ||
|
||
```shell | ||
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 | ||
``` | ||
|
||
We can see the following output: | ||
|
||
```shell | ||
managed-by: kcl-operator | ||
``` | ||
|
||
We can see that the Nginx Pod automatically added the annotation `managed-by=kcl-operator`. | ||
|
||
In addition, besides referencing an existing model for the source field of the `KCLRun` resource, we can directly set KCL code for the source field to achieve the same effect. For example: | ||
|
||
```yaml | ||
apiVersion: krm.kcl.dev/v1alpha1 | ||
kind: KCLRun | ||
metadata: | ||
name: set-annotation | ||
spec: | ||
params: | ||
annotations: | ||
managed-by: kcl-operator | ||
# Resource modification can be achieved with just one line of KCL code | ||
source: | | ||
items = [item | {metadata.annotations: option("params").annotations} for item in option("items")] | ||
``` | ||
We have provided more than 30 built-in models, and you can find more code examples in the following link: [https://github.com/kcl-lang/krm-kcl/tree/main/examples](https://github.com/kcl-lang/krm-kcl/tree/main/examples) | ||
### IDE Extension Updates | ||
In the past two weeks, we have integrated the KCL language server LSP into NeoVim and Idea, enabling the completion, navigation, and hover features supported by VS Code IDE in NeoVim and IntelliJ IDEA. | ||
+ NeoVim KCL Extension | ||
![kcl.nvim](/img/docs/tools/Ide/neovim/overview.png) | ||
+ IntelliJ Extension | ||
![intellij](/img/docs/tools/Ide/intellij/overview.png) | ||
For more information on downloading, installation, and features of the IDE plugins, please refer to: | ||
+ [https://kcl-lang.io/docs/user_docs/getting-started/install#neovim](https://kcl-lang.io/docs/user_docs/getting-started/install#neovim) | ||
+ [https://kcl-lang.io/docs/user_docs/getting-started/install#intellij-idea](https://kcl-lang.io/docs/user_docs/getting-started/install#intellij-idea) | ||
## Resources | ||
❤️ Thanks to all KCL users and community members for their valuable feedback and suggestions in the community. | ||
For more resources, please refer to | ||
- [KCL Website](https://kcl-lang.io/) | ||
- [KusionStack Website](https://kusionstack.io/) | ||
- [KCL 2023 Roadmap](https://kcl-lang.io/docs/community/release-policy/roadmap) | ||
- [KCL v0.6.0 Milestone](https://github.com/kcl-lang/kcl/milestone/6) | ||
- [KCL Github Issues](https://github.com/kcl-lang/kcl/issues) | ||
- [KCL Github Discussion](https://github.com/orgs/kcl-lang/discussions) | ||
- [KCL Community](https://github.com/kcl-lang/community) |
176 changes: 176 additions & 0 deletions
176
i18n/zh-CN/docusaurus-plugin-content-blog/2023-09-06-biweekly-newsletter/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
--- | ||
slug: 2023-09-06-biweekly-newsletter | ||
title: KCL 社区开源双周报 (2023 08.24 - 09.06) | Kubernetes Operator,IDE 插件和 v0.5.6 版本正式发布! | ||
authors: | ||
name: KCL 团队 | ||
title: KCL 团队 | ||
tags: [KCL, Biweekly-Newsletter] | ||
--- | ||
|
||
![](/img/biweekly-newsletter-zh.png) | ||
|
||
[KCL](https://github.com/kcl-lang) 是一个开源的基于约束的记录及函数语言并通过成熟的编程语言技术和实践来改进对大量繁杂配置比如云原生 Kubernetes 配置场景的编写,致力于构建围绕配置的更好的模块化、扩展性和稳定性,更简单的逻辑编写,以及更简单的自动化和生态工具集成。 | ||
|
||
本栏目将会双周更新 KCL 语言社区最新动态,包括功能、官网更新和最新的社区动态等,帮助大家更好地了解 KCL 社区! | ||
|
||
***KCL 官网:[https://kcl-lang.io](https://kcl-lang.io)*** | ||
|
||
## 内容概述 | ||
|
||
感谢所有贡献者过去两周 (2023 08.24 - 09.06) 的杰出工作,以下是重点合并内容概述 | ||
|
||
**🔧 语言及工具链更新** | ||
|
||
- KCL 导入工具更新 - 支持由 JSON/YAML 数据导出为 KCL 配置 | ||
- KCL IDE 更新 - 支持右键一键格式化能力,支持直接格式化单个文件或部分 KCL 代码 | ||
- KCL 文档工具更新 - 导出文档支持 HTML 转义 | ||
- KCL 包管理工具 KPM 更新 - kpm run 运行命令以及错误信息优化,支持直接运行位于本地路径的 KCL 包 | ||
- KCL 语言更新 - 优化系统库类型检查等错误信息及错误信息代码统一 | ||
|
||
**📰 官网和用例更新** | ||
|
||
- KCL 官网新增 v0.5.6 文档版本 | ||
- 新增通过 Github Action 发布 KCL 代码包直接发布到 docker.io 和 ghcr.io 等 Registry 用例: *[https://github.com/kcl-lang/kpm/blob/main/docs/push_by_github_action.md](https://github.com/kcl-lang/kpm/blob/main/docs/push_by_github_action.md)* | ||
- 新增 KCL Operator 集成用例: *[https://kcl-lang.io/docs/user_docs/guides/working-with-k8s/mutate-manifests/kcl-operator](https://kcl-lang.io/docs/user_docs/guides/working-with-k8s/mutate-manifests/kcl-operator)* | ||
|
||
## 特别鸣谢 | ||
|
||
以下排名不分先后 | ||
|
||
- 感谢 @jakezhu9 对 KCL Import 工具 JSON 和 YAML 配置数据到 KCL 配置块转换的贡献 🙌 *[https://github.com/kcl-lang/kcl-go/pull/141](https://github.com/kcl-lang/kcl-go/pull/141)* | ||
- 感谢 @xxmao123 和 @starkers 对 KCL NeoVim 以及 Idea IDE 插件的贡献 🙌 *https://github.com/kcl-lang/intellij-kcl/pull/12* | ||
- 此外感谢 @kolloch, @prahaladramji 等在过去两周使用 KCL 过程中提出的宝贵反馈和讨论 🙌 | ||
|
||
**祝贺 @jakezhu9 祝贺 jakezhu9 成为 KCL 社区 Maintainer** 🎉 | ||
|
||
## 精选更新 | ||
|
||
### KCL Operator | ||
|
||
KCL Operator 提供了 Kubernetes 集群集成,允许您在将资源应用到集群时使用 Access Webhook 根据 KCL 配置生成、变异或验证资源。Webhook 将捕获创建、应用和编辑操作,并 `KCLRun` 在与每个操作关联的配置上执行资源,比如可以使用 KCL 语言完成如下功能 | ||
|
||
+ 使用 KCL 对资源进行修改,如根据某个条件添加/修改 label 标签或 annotation 注释或在包含 PodTemplate 的所有 Kubernetes Resource Model (KRM) 资源中注入 Sidecar 容器配置等。 | ||
+ 使用 KCL Schema 验证所有 KRM 资源,如约束只能以 Root 方式启动容器等。 | ||
+ 使用抽象模型生成 KRM 资源或者对不同的 KRM API 进行组合并使用。 | ||
|
||
使用 KCL Operator, 通过几个步骤您就可以在 Kubernetes 集群内部以很轻量的方式地通过 KCL 代码自动化地完成资源配置的管理和安全验证,无需重复开发 Webhook Server 在运行时动态修改和验证配置。 | ||
|
||
此外借助 KCL 良好的建模和抽象能力,我们可以为不同的资源 API 定义进行功能抽象/组合并以 KCL Schema 的形式对外透出,并且可以由 KCL Schema 进一步自动生成 OpenAPI Schema 定义供集群其他客户端调用,而无需为 API 抽象/组合手动维护复杂的 OpenAPI Schema 定义。 | ||
|
||
下面以一个简单的资源 annotation 注解修改示例介绍 KCL Operator 的使用方式 | ||
|
||
#### 0.前置条件 | ||
|
||
通过 k3d 等工具准备一个 Kubernetes 集群以及 kubectl 工具 | ||
|
||
#### 1. 安装 KCL Operator | ||
|
||
```shell | ||
kubectl apply -f https://raw.githubusercontent.com/kcl-lang/kcl-operator/main/config/all.yaml | ||
``` | ||
|
||
使用以下命令观察并等待 pod 状态为 Running。 | ||
|
||
``` | ||
kubectl get po | ||
``` | ||
|
||
#### 2. 部署注解修改模型 | ||
|
||
```shell | ||
kubectl apply -f- << EOF | ||
apiVersion: krm.kcl.dev/v1alpha1 | ||
kind: KCLRun | ||
metadata: | ||
name: set-annotation | ||
spec: | ||
# 设置注解修改模型所需的动态参数,在此处我们可以添加我们想要修改/添加的标签 | ||
params: | ||
annotations: | ||
managed-by: kcl-operator | ||
# 引用 OCI 上注解修改模型 | ||
source: oci://ghcr.io/kcl-lang/set-annotation | ||
EOF | ||
``` | ||
|
||
#### 3. 部署一个 Pod 资源验证模型结果 | ||
|
||
执行如下命令部署一个 Pod 资源 | ||
|
||
```shell | ||
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 | ||
``` | ||
|
||
我们可以看到如下输出 | ||
|
||
```shell | ||
managed-by: kcl-operator | ||
``` | ||
|
||
我们可以发现 Nginx Pod 上自动添加了 `managed-by=kcl-operator` 注解 | ||
|
||
此外,除了为 `KCLRun` 资源 `source` 字段引用已有的模型,我们可以直接为 `source` 字段设置 KCL 代码也可以达到同样的效果,比如 | ||
|
||
```yaml | ||
apiVersion: krm.kcl.dev/v1alpha1 | ||
kind: KCLRun | ||
metadata: | ||
name: set-annotation | ||
spec: | ||
params: | ||
annotations: | ||
managed-by: kcl-operator | ||
# 仅通过一行 KCL 代码就可完成资源的修改 | ||
source: | | ||
items = [item | {metadata.annotations: option("params").annotations} for item in option("items")] | ||
``` | ||
我们已经开箱提供了多达 30+ 的内置模型,您可以在下面的链接中获得更多代码示例 | ||
https://github.com/kcl-lang/krm-kcl/tree/main/examples | ||
### KCL IDE 插件更新 | ||
过去两周,我们将 KCL 语言服务器 LSP 集成到了 NeoVim 和 Idea 中,使得可以在 NeoVim 和 IntelliJ IDEA 中体验到和 VS Code IDE 支持的补全、跳转和悬停等功能 | ||
+ NeoVim KCL 插件 | ||
![kcl.nvim](/img/docs/tools/Ide/neovim/overview.png) | ||
+ IntelliJ 插件 | ||
![intellij](/img/docs/tools/Ide/intellij/overview.png) | ||
更多 IDE 插件下载安装方式和功能说明可参考: | ||
+ https://kcl-lang.io/docs/user_docs/getting-started/install#neovim | ||
+ https://kcl-lang.io/docs/user_docs/getting-started/install#intellij-idea | ||
## 其他资源 | ||
❤️ 感谢所有 KCL 用户和社区小伙伴在社区中提出的宝贵反馈与建议。预计 9 月中旬我们会正式发布 KCL v0.6 新版本,敬请期待! | ||
更多其他资源请参考: | ||
- [KCL 网站](https://kcl-lang.io/) | ||
- [KusionStack 网站](https://kusionstack.io/) | ||
- [KCL 2023 路线规划](https://kcl-lang.io/docs/community/release-policy/roadmap) | ||
- [KCL v0.6.0 Milestone](https://github.com/kcl-lang/kcl/milestone/6) | ||
- [KCL Github Issues](https://github.com/kcl-lang/kcl/issues) | ||
- [KCL Github Discussion](https://github.com/orgs/kcl-lang/discussions) | ||
- [KCL Community](https://github.com/kcl-lang/community) |