{"id":20983001,"url":"https://github.com/tkestack/lb-controlling-framework","last_synced_at":"2025-05-14T16:31:57.414Z","repository":{"id":48046401,"uuid":"219715424","full_name":"tkestack/lb-controlling-framework","owner":"tkestack","description":"A controller that helps you manipulate arbitrary load balancers","archived":false,"fork":false,"pushed_at":"2023-02-15T03:30:30.000Z","size":925,"stargazers_count":56,"open_issues_count":5,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-02T20:38:35.107Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tkestack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG/CHANGELOG-1.1.1.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"docs/Roadmap.md","authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-05T10:13:39.000Z","updated_at":"2024-06-09T06:45:38.000Z","dependencies_parsed_at":"2024-06-18T22:46:15.851Z","dependency_job_id":"3ee6aeed-de8d-4867-9d13-581999d5ec38","html_url":"https://github.com/tkestack/lb-controlling-framework","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkestack%2Flb-controlling-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkestack%2Flb-controlling-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkestack%2Flb-controlling-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkestack%2Flb-controlling-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tkestack","download_url":"https://codeload.github.com/tkestack/lb-controlling-framework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254183040,"owners_count":22028405,"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":[],"created_at":"2024-11-19T05:47:24.369Z","updated_at":"2025-05-14T16:31:56.832Z","avatar_url":"https://github.com/tkestack.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Load Balancer Controlling Framework (LBCF)\n\nLBCF是一款部署在Kubernetes内的通用负载均衡控制面框架，实现了可靠的一致性保证与灵活的扩展接口。通过实现LBCF提供的扩展接口，您可以快速实现可靠的负载均衡/名字服务对接。\n\nLBCF自上线以来，没有发生过容器的错误绑定或错误解绑，这一切都源自LBCF设计了可靠的一致性保证机制，详见文档: [LBCF的一致性保证](/docs/design/lbcf-consistency-design.md)\n\n可扩展性是LBCF的核心，为此，LBCF针对负载均衡操作特点，在Pod生命周期中设计了9个可实现自定义逻辑的Webhook，webhook定义见文档：[LBCF CRD设计](/docs/design/lbcf-crd.md)\n\n---\n\n## 安装LBCF\n\n见文档:[安装LBCF](/docs/install.md)\n\n---\n##  基于LBCF实现业务逻辑\n得益于LBCF的可靠性与扩展能力，我们的用户实现了众多高度定制化的业务需求。在使用LBCF前，这些需求往往需要单独开发controller，并经过漫长的周期才能逐渐稳定。\n\n### 将Pod注册至第三方系统（负载均衡/名字服务/其他）\n标题中提到的\"第三方系统\"并不特指任何系统，只要其提供了API，并且业务需求符合\"Pod启动时注册，Pod结束时注销\"的行为模式，就都可以使用LBCF。LBCF的一些用户就实现了将Pod注册至自己内部系统的功能。\n\n#### Pod生命周期监听\n使用LBCF后，您无需自行实现Pod生命周期的监听，您只需在接收端（在LBCF中称为Driver）实现自己的业务逻辑即可。LBCF会在以下时刻触发Webhook：\n* Pod非Ready --\u003e Pod Ready  \n* Pod Ready --\u003e Pod非Ready  \n* Pod 被设置`deletionTimestamp`  \n* Pod Ready，但不再被用户指定为需要注册\n* Pod Ready，并重新被用户指定为需要注册    \nPS: 当Pod发生扩/缩容时，LBCF也会自动响应。\n\n#### 调用第三方API\n当Webhook触发时，Webhook请求中会携带相关Pod的信息，您可以按需进行信息处理与第三方API调用：  \n[generateBackendAddr](/docs/design/lbcf-webhook-specification.md#generatebackendaddr): 用于生成注册Pod时使用的参数  \n[ensureBackend](/docs/design/lbcf-webhook-specification.md#ensurebackend): 用于将`generateBackendAddr`生成的参数注册至第三方系统  \n[deregisterBackend](/docs/design/lbcf-webhook-specification.md#deregisterbackend): 用于将`generateBackendAddr`生成的参数从第三方系统注销  \n\n#### 第三方系统的自定义参数\n调用第三方系统API时必然要填写一些系统相关参数，这些参数不可能完全来自K8S。因此，LBCF允许Driver实现自定义参数，并支持Driver对用户输入进行校验。\n\n#### 面向平台使用者的系统运维\n阅读系统日志是困难且痛苦的，为此，LBCF将Webhook的响应与系统关键状态都以K8S event的形式输出至了相关CRD对象中，用户使用`kubectl describe`命令就可以看到系统状态。\n更重要的是，这些event中包含的是Driver返回的业务信息，而不是LBCF的内部信息，即便用户对LBCF一无所知，依然可以明白系统在何时发生了什么。  \n以下event摘自真实环境，其中`addr`中的内容就是由Driver定义的\n```yaml\nEvents:\n  Type    Reason             Age   From             Message\n  ----    ------             ----  ----             -------\n  Normal  SuccGenerateAddr   22s   lbcf-controller  addr: {\"instanceID\":\"\",\"eIP\":\"10.0.3.244\",\"port\":80}\n  Normal  SuccEnsureBackend  16s   lbcf-controller  Successfully ensured backend\n```\n\n### 可选的Pod解绑条件\nK8S中对Pod是否需要解绑的判断依据主要是Pod的`Ready`条件和`deletionTimestamp`，LBCF完全支持这种判断，同时还提供了2种新的判断条件：\n* 按Running状态判断解绑：kubelet在某些情况下会影响Pod Ready的值（[issue #78733](https://github.com/kubernetes/kubernetes/issues/78733))，虽然可以快速回复，但对于一些金融类业务的用户来说，这依然是不可接受的\n* 自定义解绑条件：一些K8S平台提供了Pod镜像快速升级的功能，为了进一步减小业务中断时间，Pod在此种情况下不需要在状态变化而解绑。为了将这种快速升级与Pod的异常状态进行区分，这些快速升级技术通常都对Pod进行了特殊处理。\n具体设计见文档：[可配置的解绑条件设计](/docs/design/proposal/deregister-policy.md)\n\n### 已实现的业务需求 \n业务需求从来不会因K8S的限制而发生改变，这些业务对负载均衡的使用提出了多种多样的需求，这些需求都可以在LBCF的框架内通过自定义逻辑实现。\n\n#### 高度定制化的业务需求\n以下需求来自LBCF服务的某**一个**真实业务：\n* 每个Pod独占一个LB端口\n* 每20个Pod使用一个LB\n* Pod扩容时，LB也需要扩容（购买新的LB）\n* Pod缩容时，LB也需要缩容（删除LB）\n* 所有Pod都来自同一个statefulset，不接受使用多个statefulset的方案\n* Pod使用了快速升级技术，期间Pod状态会变为`Pending`，但不允许解绑\n* 必须能兼容K8S常规的Pod状态变化（非Ready的Pod需要被解绑）\n* LB的接口存在诸多限制，不能同时处理2个请求（调用API时需由调用方加锁）  \n\n#### 对网络有限制的LB\n有些LB会对容器网络提出额外需求，需要在注册Pod地址时进行一些定制化配置，由于LBCF是一个纯控制面框架，因此这种LB也可以使用LBCF对接。\n\n## LBCF设计文档\n\n* [LBCF架构设计](/docs/design/lbcf-architecture.md)\n\n* [LBCF CRD设计](/docs/design/lbcf-crd.md)\n\n* [LBCF Webhook规范](/docs/design/lbcf-webhook-specification.md)\n\n* [操作手册](/docs/design/how-to-use.md)\n\n* [一些feature设计](/docs/design/proposal)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkestack%2Flb-controlling-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftkestack%2Flb-controlling-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkestack%2Flb-controlling-framework/lists"}