{"id":19578480,"url":"https://github.com/kcl-lang/flux-kcl-controller","last_synced_at":"2025-04-27T06:33:34.159Z","repository":{"id":219941620,"uuid":"750328177","full_name":"kcl-lang/flux-kcl-controller","owner":"kcl-lang","description":"Flux KCL Controller","archived":false,"fork":false,"pushed_at":"2025-04-24T13:15:49.000Z","size":976,"stargazers_count":25,"open_issues_count":8,"forks_count":8,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-24T14:29:43.531Z","etag":null,"topics":["gitops"],"latest_commit_sha":null,"homepage":"https://kcl-lang.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kcl-lang.png","metadata":{"files":{"readme":"README-zh.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-30T12:42:57.000Z","updated_at":"2025-04-24T10:32:47.000Z","dependencies_parsed_at":"2024-02-04T09:28:13.335Z","dependency_job_id":"7e04bc26-f0ea-4d0d-b879-010792111d06","html_url":"https://github.com/kcl-lang/flux-kcl-controller","commit_stats":null,"previous_names":["kcl-lang/kcl-controller"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcl-lang%2Fflux-kcl-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcl-lang%2Fflux-kcl-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcl-lang%2Fflux-kcl-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcl-lang%2Fflux-kcl-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kcl-lang","download_url":"https://codeload.github.com/kcl-lang/flux-kcl-controller/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251099351,"owners_count":21536146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gitops"],"created_at":"2024-11-11T07:11:39.486Z","updated_at":"2025-04-27T06:33:33.733Z","avatar_url":"https://github.com/kcl-lang.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eFlux KCL controller\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"./README.md\"\u003eEnglish\u003c/a\u003e | \u003ca href=\"./README-zh.md\"\u003e简体中文\u003c/a\u003e\n\u003c/p\u003e\n\n\n# 介绍\n\nflux-kcl-controller 是一个组件，用于集成 [KCL](https://github.com/kcl-lang/kcl) 和 [Flux](https://github.com/fluxcd/flux2), 主要用来根据存储在 git/oci 仓库中的 KCL 程序定义的基础设施和工作负载，通过 [source-controller](https://github.com/fluxcd/source-controller) 获取 KCL 程序，实现基础设施和工作负载的持续交付。\n\n![kcl-flux](./docs/img/kcl-flux.png)\n\n# 特性\n\n- 定期监控存储 KCL 程序的 git/oci 仓库，并根据 git 仓库中的变化，调谐 k8s 集群状态。\n\n# 快速开始\n\n## 前提条件\n\n- k3d: 用于创建测试用的 k8s 集群，如果你已经有了 k8s 集群，可以忽略这一步。\n- Kustomize\n- Kubectl\n\n## 创建测试用的 k8s 集群\n\n通过如下命令创建集群：\n\n```shell\nk3d cluster create\n```\n\n## 下载 kcl-controller 并且安装到集群中\n\nclone 本仓库到本地：\n\n```shell\ngit clone https://github.com/kcl-lang/flux-kcl-controller.git\n```\n\n进入到本仓库的根目录：\n\n```shell\ncd flux-kcl-controller\n```\n\n将 kcl-controller 安装到集群中：\n\n```shell\nmake deploy\n```\n\n## 监控一个 git 仓库\n\n我们以仓库 https://github.com/awesome-kusion/kcl-deployment 为例，该仓库中存储了一个 KCL 程序，该程序定义了一个 Deployment，我们将使用 `flux-kcl-controller` 来部署该程序。\n\n通过 `gitrepo.yaml` 文件，定义一个 `GitRepository` 对象，用来监控该仓库：\n\n```yaml\napiVersion: source.toolkit.fluxcd.io/v1\nkind: GitRepository\nmetadata:\n  name: kcl-deployment\n  namespace: source-system\nspec:\n  interval: 30s # 每隔 30s 检查一次仓库\n  url: https://github.com/awesome-kusion/kcl-deployment.git\n  ref:\n    branch: main # 监控 main 分支\n---\napiVersion: krm.kcl.dev.fluxcd/v1alpha1\nkind: KCLRun\nmetadata:\n  name: kcl-deployment\n  namespace: source-system\nspec:\n  sourceRef:\n    kind: GitRepository\n    name: kcl-deployment\n```\n\n使用命令 `kubectl apply -f gitrepo.yaml` 将该对象部署到集群中。\n\n## 查看部署结果\n\n使用命令 `kubectl get deployment` 查看部署结果：\n\n```shell\nNAME               READY   UP-TO-DATE   AVAILABLE   AGE\nnginx-deployment   1/1     1            0           28s\n```\n\n可以看到，kcl-controller 根据仓库中的 KCL 程序，创建了一个 Deployment。\n\n## 更新仓库中的 KCL 程序\n\n我们可以通过修改仓库中的 KCL 程序，来更新集群中的 Deployment。\n\n修改仓库中的 KCL 程序，将 nginx 的版本从 `1.7.7` 修改为 `1.7.8`，将`deployment`的名字改为 `nginx-deployment-1`，并且提交到 main 分支。\n\n具体变化可以参考:\n[nginx:1.7.7 deployment](https://github.com/awesome-kusion/kcl-deployment/commit/dc8b2aa70b1b47bef0637212ea184792b8c43449) -\u003e [nginx:1.7.8 deployment](https://github.com/awesome-kusion/kcl-deployment/commit/f257a71fdff6cb9190f49c1dbf5fa4496d7b3cb2)\n\n\n使用命令 `kubectl get deployment` 查看部署结果：\n\n```shell\nNAME               READY   UP-TO-DATE   AVAILABLE   AGE\nNAME                 READY   UP-TO-DATE   AVAILABLE   AGE\nnginx-deployment     1/1     1            1           20m\nnginx-deployment-1   1/1     1            0           4s\n```\n\n可以看到，`flux-kcl-controller` 根据仓库中的 KCL 程序，创建了一个 `nginx-deployment-1` 资源。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkcl-lang%2Fflux-kcl-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkcl-lang%2Fflux-kcl-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkcl-lang%2Fflux-kcl-controller/lists"}