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

Commit 7d6e64c

Browse files
committed
packet: remove BGP management from worker pool Terraform module
This is now done via Packet CCM. Refs #548 Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
1 parent 023b2fc commit 7d6e64c

File tree

3 files changed

+4
-73
lines changed

3 files changed

+4
-73
lines changed

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

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,6 @@ systemd:
3434
ExecStart=/bin/sh -c 'while ! /usr/bin/grep '^[^#[:space:]]' /etc/resolv.conf > /dev/null; do sleep 1; done; /opt/wait-for-dns ${dns_zone} ${cluster_name}-private 3600'
3535
[Install]
3636
RequiredBy=kubelet.service
37-
%{~ if bgp_node_labels != "" ~}
38-
- name: bgp-metadata.service
39-
enable: true
40-
contents: |
41-
[Unit]
42-
Description=Write BGP metadata to disk
43-
Before=kubelet.service
44-
[Service]
45-
Type=oneshot
46-
RemainAfterExit=true
47-
ExecStart=/opt/bgp-metadata
48-
[Install]
49-
RequiredBy=kubelet.service
50-
%{~ endif ~}
5137
- name: coreos-metadata.service
5238
enable: true
5339
contents: |
@@ -69,7 +55,6 @@ systemd:
6955
Wants=rpc-statd.service
7056
[Service]
7157
EnvironmentFile=/run/metadata/flatcar
72-
EnvironmentFile=-/run/metadata/bgp
7358
EnvironmentFile=/etc/kubernetes/kubelet.env
7459
ExecStartPre=/bin/mkdir -p /var/lib/kubelet/volumeplugins
7560
ExecStartPre=/bin/mkdir -p /etc/kubernetes/manifests
@@ -123,11 +108,7 @@ systemd:
123108
--node-labels=$${NODE_LABELS} \
124109
--node-labels=lokomotive.alpha.kinvolk.io/public-ipv4=$${COREOS_PACKET_IPV4_PUBLIC_0} \'
125110
--node-labels=lokomotive.alpha.kinvolk.io/bgp-enabled=$${BGP_ENABLED} \
126-
%{~ if bgp_node_labels != "" ~}
127-
--node-labels=$${BGP_NODE_LABELS} \
128-
--node-labels=metallb.lokomotive.io/peer-address=$${BGP_PEER_ADDRESS_0} \
129111
--node-labels=metallb.lokomotive.io/src-address=$${COREOS_PACKET_IPV4_PRIVATE_0} \
130-
%{~ endif ~}
131112
--pod-manifest-path=/etc/kubernetes/manifests \
132113
--read-only-port=0 \
133114
--register-with-taints=$${NODE_TAINTS} \
@@ -304,7 +285,6 @@ storage:
304285
KUBELET_IMAGE_URL=quay.io/poseidon/kubelet
305286
KUBELET_IMAGE_TAG=v1.19.3-${os_arch}
306287
NODE_LABELS="${join(",", [for k, v in node_labels : "${k}=${v}"])}"
307-
BGP_NODE_LABELS="${bgp_node_labels}"
308288
NODE_TAINTS="${join(",", [for k, v in taints : "${k}=${v}"])}"
309289
BPG_ENABLED="${!disable_bgp}"
310290
- path: /etc/sysctl.d/max-user-watches.conf
@@ -432,41 +412,6 @@ storage:
432412
done
433413
echo "$record.$zone is available on all nameservers"
434414
exit 0
435-
- path: /opt/bgp-metadata
436-
filesystem: root
437-
mode: 0544
438-
contents:
439-
inline: |
440-
#!/bin/bash
441-
set -o pipefail
442-
max_attempts=3600
443-
target=/run/metadata/bgp
444-
echo "Polling metadata service for BGP information"
445-
counter=0
446-
while [[ $counter -lt $max_attempts ]]; do
447-
out=$(curl -s -f --connect-timeout 5 \
448-
https://metadata.packet.net/metadata | jq -r .bgp_neighbors[0].peer_ips[0])
449-
ret=$?
450-
if [[ $ret -ne 0 ]]; then
451-
echo "Non-zero exit code: $ret"
452-
elif [[ "$out" = "" ]]; then
453-
echo "Empty response"
454-
elif [[ "$out" = "null" ]]; then
455-
echo "Null response"
456-
else
457-
echo "BGP metadata is available!"
458-
if [[ ! "$out" =~ ^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}$ ]]; then
459-
echo "Invalid IP $out"
460-
exit 1
461-
fi
462-
echo "BGP_PEER_ADDRESS_0=$out" > "$target"
463-
exit $?
464-
fi
465-
sleep 1
466-
counter=$((counter+1))
467-
done
468-
echo "BGP metadata did not become available in time"
469-
exit 1
470415
passwd:
471416
users:
472417
- name: core

assets/terraform-modules/packet/flatcar-linux/kubernetes/workers/workers.tf

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,6 @@ data "ct_config" "install-ignitions" {
4343
})
4444
}
4545

46-
resource "packet_bgp_session" "bgp" {
47-
count = var.disable_bgp == true ? 0 : var.worker_count
48-
device_id = packet_device.nodes[count.index].id
49-
address_family = "ipv4"
50-
}
51-
52-
# BGP node labels.
53-
locals {
54-
my_asn = format("metallb.lokomotive.io/my-asn=%d", data.packet_project.project.bgp_config.0.asn)
55-
# Packet always uses ASN 65530 as the remote ASN for local BGP.
56-
peer_asn = format("metallb.lokomotive.io/peer-asn=%d", 65530)
57-
}
58-
5946
data "ct_config" "ignitions" {
6047
content = templatefile(
6148
"${path.module}/cl/worker.yaml.tmpl",
@@ -71,7 +58,6 @@ data "ct_config" "ignitions" {
7158
k8s_dns_service_ip = cidrhost(var.service_cidr, 10)
7259
cluster_domain_suffix = var.cluster_domain_suffix
7360
node_labels = merge({ "node.kubernetes.io/node" = "" }, var.labels)
74-
bgp_node_labels = var.disable_bgp ? "" : format("%s,%s", local.my_asn, local.peer_asn)
7561
taints = var.taints
7662
setup_raid = var.setup_raid
7763
setup_raid_hdd = var.setup_raid_hdd

0 commit comments

Comments
 (0)