{"id":51186874,"url":"https://github.com/rockops/cnidemo","last_synced_at":"2026-06-27T11:03:06.026Z","repository":{"id":359279989,"uuid":"1245335041","full_name":"rockops/cnidemo","owner":"rockops","description":"CNI from scratch with demomagic","archived":false,"fork":false,"pushed_at":"2026-06-06T21:52:09.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-06T23:18:49.496Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/rockops.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-21T06:06:58.000Z","updated_at":"2026-06-06T21:52:12.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rockops/cnidemo","commit_stats":null,"previous_names":["rockops/cnidemo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rockops/cnidemo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockops%2Fcnidemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockops%2Fcnidemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockops%2Fcnidemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockops%2Fcnidemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rockops","download_url":"https://codeload.github.com/rockops/cnidemo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockops%2Fcnidemo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34850576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-27T02:00:06.362Z","response_time":126,"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":[],"created_at":"2026-06-27T11:03:05.549Z","updated_at":"2026-06-27T11:03:06.013Z","avatar_url":"https://github.com/rockops.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cnidemo\n\nLearn how container networking and Kubernetes CNI plugins work under the hood by building container network setups from scratch using Linux kernel primitives.\n\nEach folder contains an interactive demo driven by `demo-magic.sh`.\n\n---\n\n## Step-by-Step Learning Path\n\n### [01. Network Namespaces](file:///home/ben/src/cnidemo/01-netns) (`01-netns`)\n*   **Target**: Create and inspect isolated environments.\n*   **Mechanisms**: Linux Network Namespaces (`netns`).\n*   **Goal**: Observe how a namespace segments network devices, routing tables, and firewall rules, leaving loopback (`lo`) and interfaces completely isolated from the host.\n\n### [02. Virtual Ethernet Pairs](file:///home/ben/src/cnidemo/02-veth) (`02-veth`)\n*   **Target**: Establish host-to-namespace connectivity.\n*   **Mechanisms**: Virtual Ethernet (`veth`) pairs, IP addressing, and link state activation.\n*   **Goal**: Create a virtual point-to-point network tunnel to ping between the root host namespace and the isolated namespace.\n\n### [03. Multi-Namespace Bridge](file:///home/ben/src/cnidemo/03-multi) (`03-multi`)\n*   **Target**: Interconnect multiple namespaces on the same host.\n*   **Mechanisms**: Linux Software Bridge (`br0`), multi-namespace routing, and device master attachment.\n*   **Goal**: Move from single-link connections to a virtual Layer 2 switch structure, allowing namespaces to communicate through a shared bridge gateway.\n\n### [04. TCP Socket Communication](file:///home/ben/src/cnidemo/04-com) (`04-com`)\n*   **Target**: Stream application-level traffic across namespaces.\n*   **Mechanisms**: Socket binding and TCP Layer 3 transit.\n*   **Goal**: Start a listening socket inside one namespace and connect to it from another using standard tools (`socat`, `telnet`) over the virtual bridge.\n\n### [05. Egress \u0026 External Routing](file:///home/ben/src/cnidemo/05-out) (`05-out`)\n*   **Target**: Grant namespaces external internet access.\n*   **Mechanisms**: Default routing tables (`ip route`), kernel IP forwarding, and IPTables Source NAT (masquerading).\n*   **Goal**: Route private subnet traffic from namespaces through the host's physical network adapter out to the Internet (e.g. pinging `8.8.8.8`).\n\n### [06. Multi-Host VXLAN Overlay](file:///home/ben/src/cnidemo/06-multi) (`06-multi`)\n*   **Target**: Enable networking across multiple virtual hosts (nodes).\n*   **Mechanisms**: Virtual eXtensible LAN (VXLAN) tunnels, bridge-to-tunnel aggregation, and privileged container networking.\n*   **Goal**: Connect namespaces located on separate simulated nodes (Docker containers) using a VXLAN overlay tunnel over UDP port 4789.\n\n### [07. Custom CNI Plugin](file:///home/ben/src/cnidemo/07-cni) (`07-cni`)\n*   **Target**: Implement a functional Kubernetes CNI plugin.\n*   **Mechanisms**: CNI Specification Protocol (`ADD`/`DEL`/`VERSION`), CRI-to-CNI filesystem registration, and dynamic namespace setup.\n*   **Goal**: Create a bash-written CNI plugin, deploy it inside a `kind` cluster, and observe Kubelet automatically calling it to transition pending Pods to the running state.\n\n---\n\n## Global Cleanup\n\nTo tear down all interfaces, bridges, namespaces, test containers, and local clusters created during these demos, run the global cleanup script from the root directory:\n\n```bash\nsudo ./cleanup.sh\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frockops%2Fcnidemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frockops%2Fcnidemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frockops%2Fcnidemo/lists"}