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

Update DHCP broadcast interface handling: #88

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 14 additions & 6 deletions tinkerbell/stack/templates/nginx.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{{- if .Values.stack.enabled }}
{{- $sourceInterface := .Values.stack.relay.sourceInterface -}}
{{- $macvlanInterfaceName := printf "%s%s" "macvlan" (randNumeric 2) -}}
{{- $dhcpInterfaceType := "macvlan" -}}
{{- if eq .Values.stack.relay.interfaceMode "ipvlan" -}}
{{- $dhcpInterfaceType = "ipvlan" -}}
{{- end -}}
jacobweinstock marked this conversation as resolved.
Show resolved Hide resolved
{{- $dhcpInterfaceName := printf "%s0" $dhcpInterfaceType -}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -74,7 +78,7 @@ spec:
{{- end }}
- name: {{ .Values.stack.relay.name }}
image: {{ .Values.stack.relay.image }}
args: ["-m", "{{ .Values.stack.relay.presentGiaddrAction }}", "-c", "{{ .Values.stack.relay.maxHopCount }}", "-id", "{{ $macvlanInterfaceName }}", "-iu", "eth0", "-U", "eth0", "smee.{{ .Release.Namespace }}.svc.{{ .Values.stack.clusterDomain }}."]
args: ["-m", "{{ .Values.stack.relay.presentGiaddrAction }}", "-c", "{{ .Values.stack.relay.maxHopCount }}", "-id", "{{ $dhcpInterfaceName }}", "-iu", "eth0", "-U", "eth0", "smee.{{ .Release.Namespace }}.svc.{{ .Values.stack.clusterDomain }}."]
ports:
- containerPort: 67
protocol: UDP
Expand Down Expand Up @@ -119,14 +123,18 @@ spec:
srcInterface=$(nsenter -t1 -n ip route | awk '/default/ {print $5}' | head -n1)
fi
# Create a macvlan interface. TODO: If this fails, try again with a different name?
nsenter -t1 -n ip link add {{ $macvlanInterfaceName }} link ${srcInterface} type macvlan mode bridge
{{- if eq $dhcpInterfaceType "ipvlan" }}
nsenter -t1 -n ip link add {{ $dhcpInterfaceName }} link ${srcInterface} type ipvlan mode l2
{{- else }}
nsenter -t1 -n ip link add {{ $dhcpInterfaceName }} link ${srcInterface} type macvlan mode bridge
{{- end }}
# Move the interface into the POD.
pid=$(echo $$)
nsenter -t1 -n ip link set {{ $macvlanInterfaceName }} netns ${pid} || nsenter -t1 -n ip link delete {{ $macvlanInterfaceName }}
nsenter -t1 -n ip link set {{ $dhcpInterfaceName }} netns ${pid} || nsenter -t1 -n ip link delete {{ $dhcpInterfaceName }}
# Set the macvlan interface up
ip link set {{ $macvlanInterfaceName }} up
ip link set {{ $dhcpInterfaceName }} up
# Set the IP address
ip addr add {{ .Values.stack.loadBalancerIP }}/32 dev {{ $macvlanInterfaceName }} noprefixroute
ip addr add 127.1.1.1/32 dev {{ $dhcpInterfaceName }} noprefixroute
image: alpine
securityContext:
privileged: true
Expand Down
5 changes: 4 additions & 1 deletion tinkerbell/stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ stack:
kubevip:
enabled: true
name: kube-vip
image: ghcr.io/kube-vip/kube-vip:v0.6.3
image: ghcr.io/kube-vip/kube-vip:v0.7.2
imagePullPolicy: IfNotPresent
roleName: kube-vip-role
roleBindingName: kube-vip-rolebinding
Expand All @@ -50,6 +50,9 @@ stack:
# When unset, the interface from the default route will be used.
# sourceInterface: eno1
# TODO(jacobweinstock): add feature to be able to disable listening for broadcast traffic.
# interfaceMode determines how we create the interface needed to listen for DHCP broadcast traffic.
# by default macvlan is used. ipvlan is the only other option.
# interfaceMode: ipvlan
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static defaults should generally reside in the values.yaml so consumers don't need to hunt through template code to find it.

In an actual chart, all static default values should live in the values.yaml, and should not be repeated using the default command (otherwise they would be redundant). However, the default command is perfect for computed values, which cannot be declared inside values.yaml

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice. Didn't know this. Thanks for sharing. I'll update.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


# -- Overrides
# The values defined here override those in the individual charts. Some of them require tweaking
Expand Down
Loading