{"id":18739921,"url":"https://github.com/withlin/macvlan-ipam-etcd","last_synced_at":"2025-06-16T22:05:01.829Z","repository":{"id":57568689,"uuid":"342216718","full_name":"withlin/macvlan-ipam-etcd","owner":"withlin","description":"a macvlan ipam with etcd","archived":false,"fork":false,"pushed_at":"2021-05-01T10:44:26.000Z","size":38,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-19T21:44:28.592Z","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/withlin.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}},"created_at":"2021-02-25T11:06:32.000Z","updated_at":"2021-08-21T18:12:06.000Z","dependencies_parsed_at":"2022-08-30T04:25:08.306Z","dependency_job_id":null,"html_url":"https://github.com/withlin/macvlan-ipam-etcd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/withlin/macvlan-ipam-etcd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withlin%2Fmacvlan-ipam-etcd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withlin%2Fmacvlan-ipam-etcd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withlin%2Fmacvlan-ipam-etcd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withlin%2Fmacvlan-ipam-etcd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/withlin","download_url":"https://codeload.github.com/withlin/macvlan-ipam-etcd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withlin%2Fmacvlan-ipam-etcd/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260249958,"owners_count":22980763,"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-07T15:37:53.381Z","updated_at":"2025-06-16T22:05:01.728Z","avatar_url":"https://github.com/withlin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# macvlan-ipam-etcd\na macvlan ipam with etcd\n\n## 背景\n解决macvlan使用hostlocal分配ip的ip冲突导致各种个样的bug\n\n## 如何构建\n\n```golang\n\ngo build \n\n```\n\n\n## 目前简单如何使用\n\n```shell\n\nmv macvlan-ipam-etcd  /opt/cni/bin/\n\n```\n\n\n### 测试\n\n```text\necho '{ \"cniVersion\": \"0.3.1\", \"name\": \"examplenet\", \"ipam\": { \"name\": \"myetcd-ipam\", \"type\": \"macvlan-ipam-etcd\", \"etcdConfig\": { \"etcdURL\": \"http://127.0.0.1:2379\"}, \"ranges\": [ [{\"subnet\": \"203.0.113.0/24\"}]] } }' | CNI_COMMAND=ADD CNI_CONTAINERID=example CNI_NETNS=/dev/null CNI_IFNAME=dummy0 CNI_PATH=. ./macvlan-ipam-etcd \n```\n\n### 利用libcni调用macvlan教程\n\n```text \n\n\ncat \u003e/etc/cni/net.d/10-macvlan-etcd.conf  \u003c\u003cEOF\n{\n        \"name\": \"mymacvlan\",\n        \"type\": \"macvlan\",\n        \"master\": \"ens192\",\n        \"ipam\": {\n                \"name\": \"ipam-etcd\",\n                \"type\": \"macvlan-ipam-etcd\",\n                \"etcdConfig\": {\n                        \"etcdURL\": \"http://127.0.0.1:2379\"\n                },\n                \"subnet\": \"10.22.0.0/16\",\n                \"rangeStart\": \"10.22.0.2\",\n                \"rangeEnd\": \"10.22.0.254\",\n                \"routes\": [{\n                        \"dst\": \"0.0.0.0/0\"\n                }]\n        }\n}\nEOF\n\n\n[root@node cnitool]# export CNI_PATH=/root/plugins/bin/\n[root@node cnitool]# ip netns delete a \u0026\u0026ip netns add a \u0026\u0026 ./cnitool add mymacvlan /var/run/netns/a\n2021-03-05 04:00:35.789322 I | Error retrieving last reserved ip: Can not find last reserved ip\n{\"level\":\"warn\",\"ts\":\"2021-03-05T04:00:35.791-0500\",\"caller\":\"clientv3/retry_interceptor.go:62\",\"msg\":\"retrying of unary invoker failed\",\"target\":\"endpoint://client-03e5e010-bbb2-45c5-aa5d-b895eb93129e/127.0.0.1:2379\",\"attempt\":0,\"error\":\"rpc error: code = InvalidArgument desc = etcdserver: key is not provided\"}\n{\n    \"cniVersion\": \"0.2.0\",\n    \"ip4\": {\n        \"ip\": \"10.22.0.2/16\",\n        \"gateway\": \"10.22.0.1\",\n        \"routes\": [\n            {\n                \"dst\": \"0.0.0.0/0\"\n            }\n        ]\n    },\n    \"dns\": {}\n}[root@node cnitool]# ping 10.22.0.2\nPING 10.22.0.2 (10.22.0.2) 56(84) bytes of data.\n64 bytes from 10.22.0.2: icmp_seq=1 ttl=64 time=0.087 ms\n64 bytes from 10.22.0.2: icmp_seq=2 ttl=64 time=0.099 ms\n^C\n--- 10.22.0.2 ping statistics ---\n2 packets transmitted, 2 received, 0% packet loss, time 1015ms\nrtt min/avg/max/mdev = 0.087/0.093/0.099/0.006 ms\n\n[root@node cnitool]# nsenter --net=/var/run/netns/a bash\n[root@node cnitool]# ip a\n1: lo: \u003cLOOPBACK\u003e mtu 65536 qdisc noop state DOWN group default qlen 1000\n    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\n2: eth0@if2: \u003cBROADCAST,MULTICAST,UP,LOWER_UP\u003e mtu 1500 qdisc noqueue state UP group default \n    link/ether e6:97:d2:de:e9:c8 brd ff:ff:ff:ff:ff:ff link-netnsid 0\n    inet 10.22.0.2/16 brd 10.22.255.255 scope global eth0\n       valid_lft forever preferred_lft forever\n    inet6 fe80::e497:d2ff:fede:e9c8/64 scope link \n       valid_lft forever preferred_lft forever\n\n\n```\n\n### 后续支持\n\n使用Daemonset的方式，部署到容器云。\n# macvlan-ipam-etcd\na macvlan ipam with etcd\n\n## 背景\n解决macvlan使用hostlocal分配ip的ip冲突导致各种个样的bug\n\n## 如何构建\n\n```golang\n\ngo build \n\n```\n\n\n## 目前简单如何使用\n\n```shell\n\nmv macvlan-ipam-etcd  /opt/cni/bin/\n\n```\n\n\n### 测试\n\n```text\necho '{ \"cniVersion\": \"0.3.1\", \"name\": \"examplenet\", \"ipam\": { \"name\": \"myetcd-ipam\", \"type\": \"macvlan-ipam-etcd\", \"etcdConfig\": { \"etcdURL\": \"http://127.0.0.1:2379\"}, \"ranges\": [ [{\"subnet\": \"203.0.113.0/24\"}]] } }' | CNI_COMMAND=ADD CNI_CONTAINERID=example CNI_NETNS=/dev/null CNI_IFNAME=dummy0 CNI_PATH=. ./macvlan-ipam-etcd \n```\n\n### 利用libcni调用macvlan教程\n\n```text \n\n\ncat \u003e/etc/cni/net.d/10-macvlan-etcd.conf  \u003c\u003cEOF\n{\n        \"name\": \"mymacvlan\",\n        \"type\": \"macvlan\",\n        \"master\": \"ens192\",\n        \"ipam\": {\n                \"name\": \"ipam-etcd\",\n                \"type\": \"macvlan-ipam-etcd\",\n                \"etcdConfig\": {\n                        \"etcdURL\": \"http://127.0.0.1:2379\"\n                },\n                \"subnet\": \"10.22.0.0/16\",\n                \"rangeStart\": \"10.22.0.2\",\n                \"rangeEnd\": \"10.22.0.254\",\n                \"routes\": [{\n                        \"dst\": \"0.0.0.0/0\"\n                }]\n        }\n}\nEOF\n\n\n[root@node cnitool]# export CNI_PATH=/root/plugins/bin/\n[root@node cnitool]# ip netns delete a \u0026\u0026ip netns add a \u0026\u0026 ./cnitool add mymacvlan /var/run/netns/a\n2021-03-05 04:00:35.789322 I | Error retrieving last reserved ip: Can not find last reserved ip\n{\"level\":\"warn\",\"ts\":\"2021-03-05T04:00:35.791-0500\",\"caller\":\"clientv3/retry_interceptor.go:62\",\"msg\":\"retrying of unary invoker failed\",\"target\":\"endpoint://client-03e5e010-bbb2-45c5-aa5d-b895eb93129e/127.0.0.1:2379\",\"attempt\":0,\"error\":\"rpc error: code = InvalidArgument desc = etcdserver: key is not provided\"}\n{\n    \"cniVersion\": \"0.2.0\",\n    \"ip4\": {\n        \"ip\": \"10.22.0.2/16\",\n        \"gateway\": \"10.22.0.1\",\n        \"routes\": [\n            {\n                \"dst\": \"0.0.0.0/0\"\n            }\n        ]\n    },\n    \"dns\": {}\n}[root@node cnitool]# ping 10.22.0.2\nPING 10.22.0.2 (10.22.0.2) 56(84) bytes of data.\n64 bytes from 10.22.0.2: icmp_seq=1 ttl=64 time=0.087 ms\n64 bytes from 10.22.0.2: icmp_seq=2 ttl=64 time=0.099 ms\n^C\n--- 10.22.0.2 ping statistics ---\n2 packets transmitted, 2 received, 0% packet loss, time 1015ms\nrtt min/avg/max/mdev = 0.087/0.093/0.099/0.006 ms\n\n[root@node cnitool]# nsenter --net=/var/run/netns/a bash\n[root@node cnitool]# ip a\n1: lo: \u003cLOOPBACK\u003e mtu 65536 qdisc noop state DOWN group default qlen 1000\n    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\n2: eth0@if2: \u003cBROADCAST,MULTICAST,UP,LOWER_UP\u003e mtu 1500 qdisc noqueue state UP group default \n    link/ether e6:97:d2:de:e9:c8 brd ff:ff:ff:ff:ff:ff link-netnsid 0\n    inet 10.22.0.2/16 brd 10.22.255.255 scope global eth0\n       valid_lft forever preferred_lft forever\n    inet6 fe80::e497:d2ff:fede:e9c8/64 scope link \n       valid_lft forever preferred_lft forever\n\n\n```\n\n### 后续支持\n\n1. 使用Daemonset的方式，部署到容器云。\n2. 支持读取Pod的Anno动态注解\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwithlin%2Fmacvlan-ipam-etcd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwithlin%2Fmacvlan-ipam-etcd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwithlin%2Fmacvlan-ipam-etcd/lists"}