{"id":13694238,"url":"https://github.com/labring/endpoints-operator","last_synced_at":"2025-06-11T14:39:15.911Z","repository":{"id":37443014,"uuid":"446433730","full_name":"labring/endpoints-operator","owner":"labring","description":"kubernetes endpoints balance for outsite apiserver","archived":false,"fork":false,"pushed_at":"2024-04-15T09:20:27.000Z","size":336,"stargazers_count":95,"open_issues_count":4,"forks_count":25,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-03T01:46:25.118Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/labring.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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":"2022-01-10T13:25:54.000Z","updated_at":"2025-04-24T03:04:50.000Z","dependencies_parsed_at":"2023-07-13T05:04:17.625Z","dependency_job_id":"570aef8d-5221-486a-b704-1820454f2caa","html_url":"https://github.com/labring/endpoints-operator","commit_stats":null,"previous_names":["sealyun/endpoints-operator","cuisongliu/endpoints-balance"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labring%2Fendpoints-operator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labring%2Fendpoints-operator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labring%2Fendpoints-operator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labring%2Fendpoints-operator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/labring","download_url":"https://codeload.github.com/labring/endpoints-operator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labring%2Fendpoints-operator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259280925,"owners_count":22833476,"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-08-02T17:01:27.524Z","updated_at":"2025-06-11T14:39:15.867Z","avatar_url":"https://github.com/labring.png","language":"Go","funding_links":[],"categories":["Open source library"],"sub_categories":["Cluster Management"],"readme":"# endpoints-operator\n\n\u003e 对于集群内访问集群外部服务场景使用固定的endpoint维护增加探活功能\n\n### 注意事项:\n\n- v0.1.1 版本的数据是sealyun.com的domain\n- v0.2.0 之后所有的domain都是sealos.io\n- v0.2.1 调整了Hosts配置，升级需要注意一下\n\n也可以手动执行一下脚本,namespace为xxx\n```shell\nfor cep in $(kubectl get cep -n xxx  -o jsonpath={.items[*].metadata.name});do kubectl patch cep -n xxx --type='json' -p='[{\"op\": \"replace\", \"path\": \"/metadata/finalizers\", \"value\":[]}]'  $cep;done\n```\n\n升级资源之前最好先备份一下cr删除之后再重新创建即可。\n\n## 背景\n\n- 在实际使用中，两个K8s集群之间的服务经常有互相访问和访问集群外部某些服务的需求，通常的解决方案为手动维护固定的Services和Endpoints或者直接在业务配置中写死IP，在这时候，是没有对外部服务进行探活的功能的，无法做到高可用。如果需要高可用一般是引入外部高可用LB来解决，但这样增加了复杂度，且好多公司不具备引入条件，不是最优解决方案。\n- 众所周知，Kube-Proxy的主要功能是维护集群内Services和Endpoints并在对应主机上创建对应的IPVS规则。从而达到我们可以在Pod里面通过ClusterIP访问的目的。\n\n由此，新的想法诞生了: 写一个controller，维护一个CRD来自动创建需要访问的外部服务对应的Service和Endpoint，并对创建的Endpoint中的外部服务数据（IP:PORT列表）进行探活，探活失败则移除对应的外部服务数据。\n\n## 介绍\n\nendpoints-operator是一个云原生、高可靠性、高性能、面向K8s内部服务访问外部服务的具备探活功能的4层LB。\n\n### 特性\n\n- 更加贴近云原生\n- 声明式API：探活的定义方式与Kubelet保持一致，还是熟悉的语法、熟悉的味道\n- 高可靠性：原生Service、Endpoint资源，拒绝重复造轮子\n- 高性能、高稳定：原生IPVS高性能4层负载均衡\n\n  \n\n### 核心优势\n\n- 完全使用K8s原生的Service、Endpoint资源，无自定义IPVS策略，依托K8s的Service能力，高可靠。\n- 通过controller管理一个CRD资源ClusterEndpoint（缩写cep）即可，无需手动管理Service和Endpoint两个资源\n- 完全兼容已有的自定义Service、Endpoint资源，可无缝切换至endpoints-operator管理。\n- 原生的IPVS 4层负载，未引入Nginx、HAProxy等LB，降低了复杂度，满足高性能和高稳定性的需求\n\n### 使用场景\n\n主要使用在集群内部的Pod需要访问外部服务的场景，比如数据库、中间件等，通过endpoints-operator的探活能力，可及时将有问题的后端服务剔除，避免受单个宕机副本影响，并可查看status获取后端服务健康状态和探活失败的服务。\n\n## helm 安装\n\n```bash\nVERSION=\"0.2.1\"\nwget https://github.com/labring/endpoints-operator/releases/download/v${VERSION}/endpoints-operator-${VERSION}.tgz\nhelm install -n kube-system endpoints-operator ./endpoints-operator-${VERSION}.tgz\n```\n\n## sealos 安装\n\n```bash\nsealos run labring/endpoints-operator:v0.2.1\n```\n\n## Usage\n\n```yaml\napiVersion: sealos.io/v1beta1\nkind: ClusterEndpoint\nmetadata:\n  name: wordpress\n  namespace: default\nspec:\n  periodSeconds: 10\n  ports:\n    - name: wp-https\n      hosts:\n        ## 端口相同的hosts\n        - 10.33.40.151\n        - 10.33.40.152\n      protocol: TCP\n      port: 38081\n      targetPort: 443\n      tcpSocket:\n        enable: true\n      timeoutSeconds: 1\n      failureThreshold: 3\n      successThreshold: 1\n    - name: wp-http\n      hosts:\n        ## 端口相同的hosts\n        - 10.33.40.151\n        - 10.33.40.152\n      protocol: TCP\n      port: 38082\n      targetPort: 80\n      httpGet:\n        path: /healthz\n        scheme: http\n      timeoutSeconds: 1\n      failureThreshold: 3\n      successThreshold: 1      \n    - name: wp-udp\n      hosts:\n        ## 端口相同的hosts\n        - 10.33.40.151\n        - 10.33.40.152\n      protocol: UDP\n      port: 38003\n      targetPort: 1234\n      udpSocket:\n        enable: true\n        data: \"This is flag data for UDP svc test\"\n      timeoutSeconds: 1\n      failureThreshold: 3\n      successThreshold: 1\n    - name: wp-grpc\n      hosts:\n        ## 端口相同的hosts\n        - 10.33.40.151\n        - 10.33.40.152\n      protocol: TCP\n      port: 38083\n      targetPort: 8080\n      grpc:\n        enable: true\n      timeoutSeconds: 1\n      failureThreshold: 3\n      successThreshold: 1\n```\n\n## 总结\n\"endpoints-operator” 的引入，对产品无侵入以及云原生等特性解决了在集群内部访问外部服务等问题。这个思路将会成为以后开发或者运维的标配，也是一个比较完善的项目，从开发的角度换个思路更优雅的去解决一些问题。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabring%2Fendpoints-operator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flabring%2Fendpoints-operator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabring%2Fendpoints-operator/lists"}