{"id":30547305,"url":"https://github.com/open-kingfisher/king-preset","last_synced_at":"2025-08-28T02:58:10.655Z","repository":{"id":144298334,"uuid":"255880055","full_name":"open-kingfisher/king-preset","owner":"open-kingfisher","description":"Pod Preset By Admission Controller","archived":false,"fork":false,"pushed_at":"2020-08-07T01:46:03.000Z","size":70,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-19T04:16:28.928Z","etag":null,"topics":["admission-controller","fix-pod-ip","mutating-webhook","pod","preset","validating-webhook"],"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/open-kingfisher.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-04-15T10:16:15.000Z","updated_at":"2024-03-19T13:04:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"c6c4f6b9-8972-4cd9-bf9a-6fd59a7a1c83","html_url":"https://github.com/open-kingfisher/king-preset","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/open-kingfisher/king-preset","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-kingfisher%2Fking-preset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-kingfisher%2Fking-preset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-kingfisher%2Fking-preset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-kingfisher%2Fking-preset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/open-kingfisher","download_url":"https://codeload.github.com/open-kingfisher/king-preset/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-kingfisher%2Fking-preset/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272425608,"owners_count":24932903,"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","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["admission-controller","fix-pod-ip","mutating-webhook","pod","preset","validating-webhook"],"created_at":"2025-08-28T02:58:06.407Z","updated_at":"2025-08-28T02:58:10.629Z","avatar_url":"https://github.com/open-kingfisher.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kingfisher king-preset\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)\n[![Go Report Card](https://goreportcard.com/badge/github.com/open-kingfisher/king-preset)](https://goreportcard.com/report/github.com/open-kingfisher/king-preset)\n\n通过准入控制器实现根据需求对Kubernetes相关资源进行预设操作，如：sidecar注入，pod ip地址固定等，Service扩展外部IP等\n\n## 依赖\n\n- Golang： `Go \u003e= 1.13`\n- Kubernetes CNI: Calico \u003e= 3.11.2\n- Kubernetes: 开启 ValidatingAdmissionWebhook, MutatingAdmissionWebhook 准入控制器\n\n## 特性\n\n- 实现`Pod IP地址固定`的需求，对于需要固定IP地址的业务可以使用此模块部署\n- 实现`Service添加Kubernetes集群外部IP`的功能\n- 实现`Service可以设置备份Pod IP`功能， 可以用于单独Pod测试\n\n## 部署\n\n* 执行deployment目录下面的deployment.sh，会根据deployment_all_in_one.yaml进行部署\n\u003e```shell\n\u003e./deployment.sh\n\u003e```\n\n## 卸载\n\n* 执行deployment目录下面的uninstall.sh\n\u003e```shell\n\u003e./uninstall.sh\n\u003e```\n\n## 使用说明\n* Pod IP地址固定\n    * 项目中deployment/statefulset.yaml为示例部署SatefulSet的YAML文件，需要注意以下几点\n        * `只能使用SatefulSet才可以`，不能使用Deployment或者DaemonSet等其他部署方式\n        * metadata.labels 和 spec.template.metadata.labels 必须添加 `fix-pod-ip: enabled` 此标签\n        * spec.template.metadata.annotations 必须添加如下类型的注解，其中一个Pod将在node01.example.kingfisher.com节点上面并绑定10.10.10.101这个IP，其他Pod以此类推\n        \u003e```yaml\n        \u003efix.pod.ip: \"[{\\\"node01.example.kingfisher.com\\\":[\\\"10.10.10.101\\\"]},{\\\"node002.example.kingfisher.com\\\":[\\\"10.10.10.102\\\"]},{\\\"node003.example.kingfisher.com\\\":[\\\"10.10.10.103\\\"]}]\"\n        \u003e```\n       * spec.replicas 副本数量必须`小于等于` spec.template.metadata.annotations 这个注释转换成列表后的长度\n\n* Service支持外部IP\n    * 项目中deployment/service.yaml为示例部署service的YAML文件，需要注意以下几点\n        * metadata.labels 添加 `endpoint-extend: endpoint-external-ip` 此标签表示开启外部IP添加功能\n        * metadata.labels 添加 `externalIP: 192.168.10.115-192.168.10.116-192.168.10.117` 代表想要添加的外部IP地址，使用`-`分隔\n        * metadata.labels 添加 `externalPort: 80-8080` 代表想要添加的外部IP的端口，使用`-`分隔`\n    * 检查配置是否生效 `kubectl get endpoints external -n kingfisher-system`\n    \n        \u003e```json\n        \u003e{\n        \u003e    \"apiVersion\": \"v1\",\n        \u003e    \"kind\": \"Endpoints\",\n        \u003e    \"metadata\": {\n        \u003e        \"annotations\": {\n        \u003e            \"endpoints.kubernetes.io/last-change-trigger-time\": \"2020-06-12T02:36:37Z\"\n        \u003e        },\n        \u003e        \"creationTimestamp\": \"2020-06-12T02:36:38Z\",\n        \u003e        \"labels\": {\n        \u003e            \"endpoint-external-ip\": \"enabled\",\n        \u003e            \"externalIP\": \"192.168.10.115-192.168.10.116-192.168.10.117\",\n        \u003e            \"externalPort\": \"80-8080\"\n        \u003e        },\n        \u003e        \"name\": \"external\",\n        \u003e        \"namespace\": \"kingfisher-system\",\n        \u003e        \"resourceVersion\": \"56564640\",\n        \u003e        \"selfLink\": \"/api/v1/namespaces/kingfisher/endpoints/external\",\n        \u003e        \"uid\": \"e1d85dbd-7bbe-4d59-96c8-21073e00e5ed\"\n        \u003e    },\n        \u003e    \"subsets\": [\n        \u003e        {\n        \u003e            \"addresses\": [\n        \u003e                {\n        \u003e                    \"ip\": \"192.168.10.115\"\n        \u003e                },\n        \u003e                {\n        \u003e                    \"ip\": \"192.168.10.116\"\n        \u003e                },\n        \u003e                {\n        \u003e                    \"ip\": \"192.168.10.117\"\n        \u003e                }\n        \u003e            ],\n        \u003e            \"ports\": [\n        \u003e                {\n        \u003e                    \"name\": \"0\",\n        \u003e                    \"port\": 80,\n        \u003e                    \"protocol\": \"TCP\"\n        \u003e                },\n        \u003e                {\n        \u003e                    \"name\": \"1\",\n        \u003e                    \"port\": 8080,\n        \u003e                    \"protocol\": \"TCP\"\n        \u003e                }\n        \u003e            ]\n        \u003e        }\n        \u003e    ]\n        \u003e}\n    \u003e```\n* Service支持备份Pod IP，一旦主IP不可用备份IP将可以使用\n    * 项目中deployment/service.yaml为示例部署service的YAML文件，需要注意以下几点\n        * metadata.labels 添加 `endpoint-extend: endpoint-backup-ip` 此标签表示开启外部IP添加功能\n        * metadata.labels 添加 `externalIP: 192.168.10.115-192.168.10.116-192.168.10.117` 代表想要暂时不启用的备份IP地址，使用`-`分隔，此IP必须是此Service可以正常选择到的Pod IP\n    * 检查配置是否生效 `kubectl get endpoints nginx -n kingfisher-system`  可以看到10.244.2.62不在其中\n    \n        \u003e```json\n        \u003e{\n        \u003e   \"apiVersion\": \"v1\",\n        \u003e    \"kind\": \"Endpoints\",\n        \u003e    \"metadata\": {\n        \u003e        \"creationTimestamp\": \"2020-06-18T02:57:40Z\",\n        \u003e        \"labels\": {\n        \u003e            \"backupIP\": \"10.244.2.62\",\n        \u003e            \"endpoint-extend\": \"endpoint-backup-ip\"\n        \u003e        },\n        \u003e        \"name\": \"nginx\",\n        \u003e        \"namespace\": \"default\",\n        \u003e       \"resourceVersion\": \"58472728\",\n        \u003e       \"selfLink\": \"/api/v1/namespaces/default/endpoints/nginx\",\n        \u003e       \"uid\": \"feb4d17d-ccc2-4042-bfd4-59ad5b45fbf1\"\n        \u003e    },\n        \u003e    \"subsets\": [\n        \u003e       {\n        \u003e           \"addresses\": [\n        \u003e               {\n        \u003e                   \"ip\": \"10.244.2.63\",\n        \u003e                   \"nodeName\": \"node03\",\n        \u003e                   \"targetRef\": {\n        \u003e                       \"kind\": \"Pod\",\n        \u003e                       \"name\": \"nginx-75b6fcb998-n6vnt\",\n        \u003e                       \"namespace\": \"default\",\n        \u003e                       \"resourceVersion\": \"58463150\",\n        \u003e                       \"uid\": \"30c17ecf-fc17-41a7-8452-e9346305ac7c\"\n        \u003e                   }\n        \u003e               }\n        \u003e           ],\n        \u003e           \"ports\": [\n        \u003e               {\n        \u003e                   \"port\": 80,\n        \u003e                   \"protocol\": \"TCP\"\n        \u003e               }\n        \u003e           ]\n        \u003e       }\n        \u003e   ]\n        \u003e}\n    \u003e```\n\n## Makefile的使用\n\n- 根据需求修改对应的REGISTRY变量，即可修改推送的仓库地址\n- 编译成二进制文件： make build\n- 生成镜像推送到镜像仓库： make push\n\n## 联系我们\n- [交流群](https://github.com/open-kingfisher/community/blob/master/contact_us/README.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-kingfisher%2Fking-preset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-kingfisher%2Fking-preset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-kingfisher%2Fking-preset/lists"}