I'm facing the below mentioned issue while using DHCP IPAM plugin + Macvlan + Multus for the additional interface creation inside my pod and assigning IP from DHCP server.
I actually went through the related issues around this problem and tried all the solutions/different configurations mentioned there. But none of them were working so far. The documentation for CNI plugin w.r.t DHCP usage also not quite clear.
Related Issues:
- https://github.com/k8snetworkplumbingwg/multus-cni/issues/291
- https://github.com/containernetworking/plugins/issues/587
- https://github.com/containernetworking/plugins/issues/371
- https://github.com/containernetworking/plugins/issues/440
- https://github.com/containernetworking/cni/issues/398
- https://github.com/containernetworking/cni/issues/225
- https://github.com/containernetworking/plugins/issues/371
Solutions Suggested:
DHCP Daemon Logs:
[root@test-node cni_plugins]# ./dhcp daemon -broadcast=true
2022/06/09 12:00:03 ac7d57597540992a1af43455da24b3210561ce12b164820ee18f583a304a/test_net_attach1/net1: acquiring lease
2022/06/09 12:00:03 Link "net1" down. Attempting to set up
2022/06/09 12:00:03 network is down
2022/06/09 12:00:03 retrying in 2.881018 seconds
2022/06/09 12:00:16 no DHCP packet received within 10s
2022/06/09 12:00:16 retrying in 2.329120 seconds
2022/06/09 12:00:29 no DHCP packet received within 10s
2022/06/09 12:00:29 retrying in 1.875428 seconds
NetworkAttachmentDefinition:
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: "test1"
annotations:
k8s.v1.cni.cncf.io/resourceName: intel.com/test_net_attach1
spec:
config:
'{
"name": "test_net_attach1",
"type": "macvlan",
"master": "ens2f0",
"ipam": {
"type": "dhcp"
}
}'
Test Pod YAML:
apiVersion: v1
kind: Pod
metadata:
name: dhcp-test1
annotations:
k8s.v1.cni.cncf.io/networks: test1
spec:
nodeSelector:
deploy: vm1
containers:
- name: c1
image: centos:latest
command: ["/bin/sh","-c"]
args: ["sleep infinity"]
DHCP SERVER Logs:
Internet Systems Consortium DHCP Server 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Config file: /data/dhcpd.conf
Database file: /data/dhcpd.leases
PID file: /var/run/dhcpd.pid
Wrote 0 leases to leases file.
Listening on LPF/ens2f0/b4:96:91:a5:8c:82/192.168.231.0/24
Sending on LPF/ens2f0/b4:96:91:a5:8c:82/192.168.231.0/24
Sending on Socket/fallback/fallback-net
Server starting service.
DHCPDISCOVER from 4a:63:ad:6d:9a:44 via ens2f0
DHCPOFFER on 192.168.231.120 to 4a:63:ad:6d:9a:44 via ens2f0
DHCPDISCOVER from 4a:63:ad:6d:9a:44 via ens2f0
DHCPOFFER on 192.168.231.120 to 4a:63:ad:6d:9a:44 via ens2f0
Observations:
- DHCP request and response are seen by tcpdump on the interface but the dhcp daemon says none was received.
- Looks like the DHCP daemon is not picking up the offer.
ENVIRONMENT: CNI: cni-plugins-linux-amd64-v1.1.1.tgz
Could someone please share the working configurations for the below mentioned items
- Network attachment definition
- Sample Pod YAML
- How to run DHCP Daemon?
for the better documentation and for the new comers who is facing issues around this? Please let me know if you needed anything or if I'm missing anything?