Skip to content
This repository was archived by the owner on Jun 29, 2022. It is now read-only.

Commit 7f1d1cd

Browse files
committed
packet: Read BGP peer address from metadata service
In some Packet facilities the BGP peer address isn't the same as the gateway address allocated for a host. Rather, it is a loopback address that's reachable via the gateway. The Packet metadata service now exposes BGP info to hosts, so we can query the metadata service for the BGP peer address. We currently use the first peer address only since MetalLB doesn't support multiple node peers yet. The source address is explicitly specified since when the peer address is a loopback address, the source IP addresses which ends up getting selected by the kernel is the node's *public* address which doesn't work. In cases where the peer address is the gateway address there is no harm in explicitly specifying the source. Fixes #1009.
1 parent 3008e5a commit 7f1d1cd

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

assets/terraform-modules/packet/flatcar-linux/kubernetes/workers/cl/worker.yaml.tmpl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,9 @@ systemd:
8282
ExecStartPre=/usr/bin/bash -c "grep 'certificate-authority-data' /etc/kubernetes/kubeconfig | awk '{print $2}' | base64 -d > /etc/kubernetes/ca.crt"
8383
ExecStartPre=-/usr/bin/rkt rm --uuid-file=/var/cache/kubelet-pod.uuid
8484
ExecStartPre=/etc/kubernetes/configure-kubelet-cgroup-driver
85-
# TODO: Workaround until https://github.com/coreos/afterburn/pull/358
86-
# makes it into Flatcar. Then we can read COREOS_PACKET_IPV4_PRIVATE_GATEWAY_0
87-
# from /run/metadata/flatcar and disable the template conditionals below.
8885
ExecStart=/bin/sh -c \
8986
"%{~ if bgp_node_labels != "" ~}
90-
BGP_PEER_ADDRESS=$(ip route | grep '10.0.0.0/8' | awk {'print $3'}); \
87+
BGP_PEER_ADDRESS=$(curl -s https://metadata.packet.net/metadata | jq -r .bgp_neighbors[0].peer_ips[0]); \
9188
%{~ endif ~}
9289
/usr/lib/coreos/kubelet-wrapper \
9390
--node-ip=$${COREOS_PACKET_IPV4_PRIVATE_0} \
@@ -112,7 +109,9 @@ systemd:
112109
--node-labels=$${NODE_LABELS} \
113110
--node-labels=lokomotive.alpha.kinvolk.io/public-ipv4=$${COREOS_PACKET_IPV4_PUBLIC_0} \
114111
%{~ if bgp_node_labels != "" ~}
115-
--node-labels=$${BGP_NODE_LABELS},metallb.lokomotive.io/peer-address=$BGP_PEER_ADDRESS \
112+
--node-labels=$${BGP_NODE_LABELS} \
113+
--node-labels=metallb.lokomotive.io/peer-address=$BGP_PEER_ADDRESS \
114+
--node-labels=metallb.lokomotive.io/src-address=$${COREOS_PACKET_IPV4_PRIVATE_0} \
116115
%{~ endif ~}
117116
--pod-manifest-path=/etc/kubernetes/manifests \
118117
--read-only-port=0 \

0 commit comments

Comments
 (0)