Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kea DHCP #181

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions deploy_partition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
roles:
- name: cumulus
tags: cumulus
- name: metal-roles/partition/roles/dhcp-relay
tags: dhcp
- name: metal-roles/partition/roles/docker-on-cumulus
tags: docker-on-cumulus

- name: Deploy dhcp server and pixiecore on leaf01
- name: Deploy pixiecore on leaf01
hosts: leaf01
vars:
setup_yaml:
Expand All @@ -44,8 +46,6 @@
roles:
- name: ansible-common
tags: always
- name: metal-roles/partition/roles/dhcp
tags: dhcp
- name: metal-roles/partition/roles/pixiecore
tags: pixiecore

Expand Down
68 changes: 68 additions & 0 deletions files/kea.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"Dhcp4": {
"option-data": [
{
"name": "domain-name-servers",
"data": "1.1.1.1, 8.8.8.8",
"always-send": true
}
],
"subnet4": [
{
"id": 1,
"subnet": "10.0.1.0/25",
"pools": [
{
"pool": "10.0.1.2 - 10.0.1.127"
}
],
"option-data": [
{
"name": "routers",
"data": "10.0.1.1"
}
]
},
{
"id": 2,
"subnet": "10.0.1.128/25",
"pools": [
{
"pool": "10.0.1.129 - 10.0.1.254"
}
],
"option-data": [
{
"name": "routers",
"data": "10.0.1.128"
}
]
}
],
"interfaces-config": {
"interfaces": [
"lo"
],
"dhcp-socket-type": "udp",
"outbound-interface": "use-routing",
},
"control-socket": {
"socket-type": "unix",
"socket-name": "/run/kea/control_socket_4"
},
"loggers": [
{
"name": "kea-dhcp4",
"output_options": [
{
"output": "stdout"
}
],
"severity": "DEBUG"
}
],
"lease-database": {
"type": "memfile"
}
}
}
2 changes: 2 additions & 0 deletions images/sonic/sonic_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def initial_configuration(g: GuestFS) -> None:
g.ln_s(linkname=systemd_system + 'featured.timer', target='/dev/null') # Feature handling not necessary
g.ln_s(linkname=systemd_system + 'hostcfgd.timer', target='/dev/null') # After boot Host configuration
# Started by featured
g.ln_s(linkname=systemd_system + 'dhcp_relay.service', target='/lib/systemd/system/dhcp_relay.service')
g.ln_s(linkname=sonic_target_wants + 'dhcp_relay.service', target='/lib/systemd/system/dhcp_relay.service')
g.ln_s(linkname=sonic_target_wants + 'lldp.service', target='/lib/systemd/system/lldp.service')

# Workaround: Only useful for BackEndToRRouter
Expand Down
2 changes: 2 additions & 0 deletions inventories/group_vars/sonic/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ sonic_ip_masquerade: true
sonic_vlans:
- id: 4000
ip: "{{ metal_core_cidr }}"
dhcp_servers:
- "{{ dhcp_relay_server }}"

# Dummy VTEP so that basic VXLAN config will be deployed by sonic role:
sonic_vteps:
Expand Down
14 changes: 1 addition & 13 deletions inventories/partition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,13 @@ leaves:
lo: 10.0.0.11
asn: 4200000011
metal_core_cidr: 10.0.1.1/{{ metal_core_cidr_mask }}

dhcp_default_lease_time: 600
dhcp_max_lease_time: 600
dhcp_subnets:
- network: 10.0.1.0
netmask: 255.255.255.0
range:
begin: 10.0.1.2
end: 10.0.1.255
options:
- routers {{ dhcp_server_ip }}
- domain-name-servers 1.1.1.1, 8.8.8.8
leaf02:
lo: 10.0.0.12
asn: 4200000012
metal_core_cidr: 10.0.1.128/{{ metal_core_cidr_mask }}
vars:
pixie_server_ip: 10.0.1.1
dhcp_server_ip: 10.0.1.1
dhcp_relay_server: 10.0.0.21

ansible_python_interpreter: /usr/bin/python
ansible_user: root
Expand Down
6 changes: 6 additions & 0 deletions mini-lab.sonic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ topology:
- files/inet/network.sh:/root/network.sh
exec:
- sh /root/network.sh
kea:
kind: linux
network-mode: container:inet # join the network namespace of inet
image: docker.cloudsmith.io/isc/docker/kea-dhcp4:2.6.0
binds:
- files/kea.json:/etc/kea/kea-dhcp4.conf
vms:
kind: linux
image: ${MINI_LAB_VM_IMAGE}
Expand Down
11 changes: 11 additions & 0 deletions roles/sonic/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,14 @@
delay: 3
register: result
until: result.rc == 0

- name: Add dummy IPv4 to Ethernet0 as workaround for dhcp relay
ansible.builtin.command: config interface ip add Ethernet0 169.254.0.1/32

- name: Set state of Ethernet0 for dhcp relay
ansible.builtin.command: sonic-db-cli STATE_DB HSET "INTERFACE_TABLE|Ethernet0|169.254.0.1/32" state ok

- name: Restart dhcp relay to see new Vlans
ansible.builtin.service:
name: dhcp_relay.service
state: restarted