{"id":16921666,"url":"https://github.com/strrl/sample-controller-rabbit","last_synced_at":"2026-05-18T01:31:36.526Z","repository":{"id":110578738,"uuid":"243940184","full_name":"STRRL/sample-controller-rabbit","owner":"STRRL","description":null,"archived":false,"fork":false,"pushed_at":"2020-03-09T05:05:27.000Z","size":60,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T08:46:06.990Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/STRRL.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"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-02-29T09:28:35.000Z","updated_at":"2020-03-09T05:05:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"8462008a-62f0-405b-96be-0e023ff5f587","html_url":"https://github.com/STRRL/sample-controller-rabbit","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STRRL%2Fsample-controller-rabbit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STRRL%2Fsample-controller-rabbit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STRRL%2Fsample-controller-rabbit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STRRL%2Fsample-controller-rabbit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/STRRL","download_url":"https://codeload.github.com/STRRL/sample-controller-rabbit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244708492,"owners_count":20496901,"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-10-13T19:52:47.302Z","updated_at":"2026-05-18T01:31:36.476Z","avatar_url":"https://github.com/STRRL.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sample-controller-rabbit\n\n## 前言\n\n最近在学习 k8s 中 CRD, controller 相关的东西, 但是又接触不到项目, 没有什么可以值得真正上手写一写的东西.\n\n所以自己想了一个这个叫做 sample-controller-rabbit 的项目, 利用 kubernetes controller 的一些特性, 来做一些有意思(无聊)的事情.\n\n## 设定\n\n在一个假设的只有兔子的世界(CRD, rabbit-world)中, 生活着一群可爱的兔子(CRD rabbit), 兔子在这个世界中生活, 繁衍, 死亡.\n\n兔子以兔子窝(CRD rabbit hole)为单位分批生存, 兔子窝可以理解为一个家庭. 同一个窝里面有父(1)母(1)以及孩子(0..n).\n\n兔子有以下几个属性:\n\n- 名字\n- 性别\n- 第 n 代\n\n兔子窝有以下几个属性:\n\n- 名字\n\n规则:\n\n- 世界最开始有一个兔子窝(eden), 里面有两只兔子(adam eve).\n- 现实世界每过一分钟, 视为兔子的年龄增加 1.\n- 兔子窝中的父母会每增加 1 年龄, 生一批新兔子.\n- 年龄合适(值域[3, 6])的两只异性兔子会选择建立新的兔子窝, 并繁育后代.\n- 兔子每次繁衍后代会增加[2, 4]只新的兔子, 性别比例 1:1.\n- 当种群数量超过某个阈值时, 兔子的繁衍欲望会为 0, 不再有新的兔子产生.\n- 当兔子大于 12 岁时, 兔子会以 ( 当前年龄 - 12 ) / 12 的几率死亡.\n\n## 设计与实现\n\n我想要的效果是设定一个兔子种群数量的预期值, 然后兔子们以某种规则慢慢 scale 到预期的数量.\n\n而且兔子也并不是稳定的, 随时有兔子死亡.\n\n### 兔子\n\n兔子要有一个 POD, 提供 WEB 服务, 输出自己的状态. 并在自己死亡的时候 kill 掉自己.\n\n兔子的属性以及繁衍欲望等相关的数据通过 Downward API 交给兔子得知.\n\n### 上帝 controller\n\n- 在兔子数量少于期望值的时候, 会找出适婚年龄的兔子来繁衍.\n- \"埋葬\" 死亡的兔子.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrrl%2Fsample-controller-rabbit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrrl%2Fsample-controller-rabbit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrrl%2Fsample-controller-rabbit/lists"}