Skip to main content

14 posts tagged with "Biweekly-Newsletter"

View All Tags

· 8 min read

KCL is a constraint-based record and functional language hosted by Cloud Native Computing Foundation (CNCF) 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

Overview

Thanks to to all contributors for their outstanding work over the past two weeks (01.19 2024 - 02.01 2024). Here is an overview of the key content:

📦 Module Updates

  • Added the podinfo application configuration module, supporting the setting of external dynamic parameters such as replicas. You can directly render Kubernetes manifests with a single command, and customize KCL templates based on this module.
kcl run oci://ghcr.io/kcl-lang/podinfo -D replicas=2

🏄 Language Updates

  • Improved error messages when object attribute are not found at compile time.
  • Fixed the recursive check error for mandatory attribute of schema objects.
  • Enhanced the robustness of type-checking for schema index signatures.

🔧 Toolchain Updates

  • Documentation Tools Updates: Added support for HTML escaping of multiline strings in generated Markdown documentation.
  • CodeQL KCL Tools: Preliminary support for the CodeQL KCL dbschema definition and data extraction from KCL syntax and semantics, enabling static analysis and scanning of KCL code through CodeQL queries to improve code security.

💻 IDE Updates

  • Semantic Highlighting

    • KCL IDE optimized semantic highlighting.
  • Enhancement for Completion Features

    • Fixed the issue with erroneous completions after strings followed by comments.
    • Fixed the issue where internal property symbols in Schema could not be navigated.

🎁 API Updates

  • Added syntax and semantic analysis APIs for analyzing KCL code.
  • Added APIs to build binary artifacts for caching compilation results.
  • Added APIs to run binary artifacts directly, avoiding recompilation and improving performance.
  • Added code generation APIs to programmatically implement KCL code generation instead of writing complex templates.

🚀 SDK Updates

  • Updated KCL Go SDK to version 0.7.5.
  • Updated KCL Python SDK to version 0.7.5.
  • Updated KCL Rust SDK to version 0.7.5.
  • Added definitions for syntax trees, scopes, symbols, and other syntactic and semantic structures to the KCL Java SDK, along with related query APIs.

For more details, visit: https://github.com/kcl-lang/lib

🚢 Integration Updates

  • In addition to the ArgoCD KCL plugin, KCL now supports GitOps for KCL configurations stored in Git/OCI repositories using the KCL Flux Controller. For more details, visit https://github.com/kcl-lang/flux-kcl-controller. Contributions are welcome 👏.

Special Thanks

The following are listed in no particular order:

  • Thanks to @octonawish-akcodes for contributions to KCL code cleanup and FAQ documents. 🙌
  • Thanks to @satyazzz123 for contributions to the KRM KCL's support for reading environment variables. 🙌
  • Thanks to @AkashKumar7902 for contributions to the KCL package management tool functionality. 🙌
  • Thanks to @UtkarshUmre for contributions to the KCL linux-arm64 build CI scripts. 🙌
  • Thanks to @steeling, @rozaliev, @CloudZero357, @martingreber, @az, @Art3mK, @AdmiralNemo, and @Erick for valuable suggestions and feedback during the past two weeks of using KCL. 🙌

Flux KCL Integration

Using KCL together with GitOps tools like Flux has the following benefits:

  • The abstraction and programmability capabilities of KCL can help simplify complex Kubernetes deployment configurations, reducing the error rate of manually writing YAML files. It allows for configuration constraint checks at compile-time, making it easier to detect errors. Additionally, it eliminates redundant configuration templates, improves the scalability of configurations across multiple environments and tenants, and enhances configurability and maintainability.
  • KCL allows developers to define the required resources for an application in a declarative manner. Combining KCL with Flux enables better implementation of Infrastructure as Code (IaC), improving deployment efficiency and simplifying application configuration management.
  • With Flux, developers and operations teams can manage the deployment of applications by separately modifying application and configuration code. The Flux Controller automatically synchronizes changes to the configuration, enabling continuous deployment and ensuring consistency. In case of issues, quick rollbacks can be achieved.

Workflow

In this example, we use a Python Flask application and GitHub Actions as a CI example. The Flux KCL Controller is deployed in the cluster as a CD example. KCL is used to define the Kubernetes resources that need to be deployed.

Note: You can use any containerized application and different CI/CD systems like GitLab CI, Jenkins CI, or ArgoCD in this scenario.

We divide the Python Flask application code and configuration code into two repositories to separate the concerns of different roles such as developers and operations teams.

The overall workflow is as follows:

  1. Pull the application code from GitHub.
  2. Develop the application code and commit it to the GitHub repository.
  3. Trigger GitHub Actions to compile the application code, generate a container image, and push the container image to the Docker Hub container registry.
  4. Trigger GitHub Actions to update the Kubernetes manifest deployment files defined by KCL based on the version of the container image in the docker.io container registry.
  5. The Flux KCL Controller retrieves the changes to the Kubernetes manifest defined by KCL and updates the deployment to the Kubernetes cluster.

Specific Steps

1. Prepare a Kubernetes Cluster
  • Install K3d and create a cluster:
k3d cluster create

Note: You can use other methods to create your own Kubernetes cluster, such as kind, minikube, etc.

  • Install kubectl
  • Install kustomize
2. Install Flux KCL Controller

flux-kcl-workflow

git clone https://github.com/kcl-lang/flux-kcl-controller.git && cd flux-kcl-controller && make deploy
3. Configure the Git Repository for Continuous Delivery

Define the GitRepository and KCLRun objects in the gitrepo.yaml file to configure the Git repository to be monitored for continuous delivery and additional parameters required for running KCL configurations.

apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: kcl-deployment
namespace: default
spec:
interval: 10s # Check the repository every 10s
url: https://github.com/kcl-lang/flask-demo-kcl-manifests.git
ref:
branch: main # Monitor the main branch
---
apiVersion: krm.kcl.dev.fluxcd/v1alpha1
kind: KCLRun
metadata:
name: kcl-git-controller
namespace: default
spec:
sourceRef:
kind: GitRepository
name: kcl-deployment

Deploy the objects to the cluster using the command kubectl apply -f gitrepo.yaml.

If you are using a private repository, you need to configure private repository access credentials using private key credentials. Refer to here for more details.

Note: You can also use OCIRepository in this scenario to continuously deliver the oci://ghcr.io/kcl-lang/podinfo configuration package mentioned at the beginning of the article. For example, the following configuration:

apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: OCIRepository
metadata:
name: podinfo
namespace: default
spec:
interval: 5m0s
url: oci://ghcr.io/kcl-lang/podinfo
ref:
tag: latest
---
apiVersion: krm.kcl.dev.fluxcd/v1alpha1
kind: KCLRun
metadata:
name: kcl-git-controller
namespace: default
spec:
sourceRef:
kind: OCIRepository
name: podinfo
4. Commit the Application Code

After submitting in the flask-demo repository, Github will automatically build a container image and push it to the Docker hub. It will also then trigger the Action of the flask-demo-kcl-manifest repository and modify the image value in the deployment manifest repository through KCL Automation API. Now let's create a submission in the flask-demo repository, and we can see that the code submission triggers the Github CI process for the application repository.

5. Configuration Automatic Update

After the Github CI process in the application repository is completed, an automatic update configuration CI will be triggered in the repository where the KCL configuration is stored and submitted to the main branch of the flask-demo-kcl-manifests repository. The commit information is as follows

  • We can obtain the deployment manifest source code for compilation and validation
git clone https://github.com/kcl-lang/flask-demo-kcl-manifests.git/
cd flask-demo-kcl-manifests
git checkout main && git pull && kcl

The output YAML is

apiVersion: apps/v1
kind: Deployment
metadata:
name: flask_demo
labels:
app: flask_demo
spec:
replicas: 1
selector:
matchLabels:
app: flask_demo
template:
metadata:
labels:
app: flask_demo
spec:
containers:
- name: flask_demo
image: "kcllang/flask_demo:6428cff4309afc8c1c40ad180bb9cfd82546be3e"
ports:
- protocol: TCP
containerPort: 5000
---
apiVersion: v1
kind: Service
metadata:
name: flask_demo
labels:
app: flask_demo
spec:
type: NodePort
selector:
app: flask_demo
ports:
- port: 5000
protocol: TCP
targetPort: 5000

From the above configuration, it can be seen that the image of the resource is indeed automatically updated to the newly constructed image value.

At the same time, the Flux KCL Controller will automatically pull the configuration and update it to the cluster. This achieves an end-to-end automation process for submitting business code and deploying Kubernetes, where only the business code needs to be submitted. Of course, it can be further combined with Flagger to implement various deployment strategies such as canary releases, blue-green deployments, etc.

Resources

❤️ Thanks to all KCL users and community members for their valuable feedback and suggestions in the community. See here to join us!

For more resources, please refer to

· 4 min read

KCL is a constraint-based record and functional language hosted by Cloud Native Computing Foundation (CNCF) 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

Overview

Thank you to all contributors for their outstanding work over the past two weeks (01.04 2024 - 01.18 2024). Here is an overview of the key content:

🌞 KCL Update

  • v0.7.4 released, adding support for Linux arm64.

🎁 API Update

  • Added APIs for syntax and semantic analysis

🔧 Toolchain Update

  • kcl-go sdk update

    • KCL Doc tool supports output in OpenAPI format.
    • Added Parsing related APIs.
  • Import tool update

    • Optimized the user experience of the import tool to generate KCL, and added support for keywords oneOf and allOf.
  • KCL Package Management Tool

    • Released v0.6.0, which supports adding dependencies via git commit.

💻 IDE Update

  • Semantic Highlighting

    • KCL IDE optimized semantic highlighting.
  • Enhancement for Completion Features

    • Fixed the completion error in nested schema definitions
    • Fixed the missing hover information

Special Thanks

The following are listed in no particular order:

  • Thanks to @jakezhu9 for his continuous contribution to the kcl import tool 🤝
  • Thanks to @AdmiralNemo, @Phillip Neumann, @Naxe, @steeling, etc. for their valuable feedback and suggestions in the use of KCL 🙌

KCL IDE Semantic Highlighting Enhancement

KCL IDE previously only supported KCL syntax highlighting, as shown in the figure below:

This year, we gradually enabled the new KCL semantic architecture model. With the support of the new semantic architecture, KCL IDE supports semantic-level highlighting, and the code related to semantics will be highlighted in the same way.

For more information about the KCL semantic architecture model, please refer to:

Unlocking Advanced Code Intelligence with the KCL Semantic Model

KCL Package Management Tool Supports Adding Git Dependencies via Commit

KCL Package Management Tool supports adding git dependencies via commit. Take https://github.com/KusionStack/catalog as an example, add commit a29e3db as a dependency. You can add it directly through the dependency in the kcl.mod file or the command line.

Edit the kcl.mod file as follows:

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", commit = "a29e3db" }

Or add it via the command line:

kcl mod add --git https://github.com/KusionStack/catalog.git --commit a29e3db

KCL Import Tool Enhancement

The import tool supports the generation with oneOf and allOf keywords. Take the oneOf keyword as an example, save the following content in the file oneof.json.

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://example.com/schemas/book.json",
"type": "object",
"properties": {
"title": {
"type": "string"
},
"author": {
"$comment": "oneOf for types",
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "integer"
}
]
},
"category": {
"$comment": "oneOf for objects",
"oneOf": [
{
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
{
"type": "object",
"properties": {
"title": {
"type": "string"
}
}
}
]
}
}
}

Through the import command, you can generate the corresponding KCL file.

kcl import oneof.json

You can see that the generated oneof.k file content is as follows.

"""
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
"""

schema Book:
r"""
Book

Attributes
----------
title : str, optional
author : str | [str] | int, optional
category : BookCategoryOneOf0 | BookCategoryOneOf1, optional
"""

title?: str
author?: str | [str] | int
category?: BookCategoryOneOf0 | BookCategoryOneOf1

schema BookCategoryOneOf0:
r"""
BookCategoryOneOf0

Attributes
----------
name : str, optional
"""

name?: str

schema BookCategoryOneOf1:
r"""
BookCategoryOneOf1

Attributes
----------
title : str, optional
"""

title?: str

Resources

❤️ Thanks to all KCL users and community members for their valuable feedback and suggestions in the community. See here to join us!

For more resources, please refer to