Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 9a82297

Browse files
committed
Fix kube-vip setup
Move the kube-vip manifest setup to after kubeadm is run, this avoids a situation where kube-vip fights with previous control plane nodes before they've joined the cluster. Move the crictl/kubectl commands to run on all control plane nodes Remove unnecessary KUBECONFIG export to save a line Signed-off-by: Chris Privitere <[email protected]>
1 parent 5f8f05d commit 9a82297

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

templates/experimental-kube-vip/kustomization.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ patches:
5757
sed -i "s,sandbox_image.*$,sandbox_image = \"$(kubeadm config images list | grep pause | sort -r | head -n1)\"," /etc/containerd/config.toml
5858
systemctl restart containerd
5959
ping -c 3 -q {{ .controlPlaneEndpoint }} && echo OK || ip addr add {{ .controlPlaneEndpoint }} dev lo
60+
postKubeadmCommands:
61+
- |
6062
curl -o /run/metadata.json -fsSL https://metadata.platformequinix.com/metadata
6163
for i in $(cat /run/metadata.json | jq -r '.bgp_neighbors[0].peer_ips[]'); do
6264
ip route add $i via $(cat /run/metadata.json | jq -r '.network.addresses[] | select(.public == false and .address_family == 4) | .gateway')
@@ -73,15 +75,12 @@ patches:
7375
--localAS $(cat /run/metadata.json | jq -r '.bgp_neighbors[0].customer_as') \
7476
--bgpRouterID $(cat /run/metadata.json | jq -r '.bgp_neighbors[0].customer_ip') > /etc/kubernetes/manifests/vip.yaml
7577
rm /run/metadata.json
76-
postKubeadmCommands:
77-
- |
78+
mkdir -p /root/.kube && cp -f /etc/kubernetes/admin.conf /root/.kube/config
79+
echo "source <(kubectl completion bash)" >> /root/.bashrc
80+
echo "alias k=kubectl" >> /root/.bashrc
81+
echo "complete -o default -F __start_kubectl k" >> /root/.bashrc
7882
if [ -f "/run/kubeadm/kubeadm.yaml" ]; then
79-
export KUBECONFIG=/etc/kubernetes/admin.conf
80-
mkdir -p /root/.kube && cp -f $${KUBECONFIG} /root/.kube/config
81-
echo "source <(kubectl completion bash)" >> /root/.bashrc
82-
echo "alias k=kubectl" >> /root/.bashrc
83-
echo "complete -o default -F __start_kubectl k" >> /root/.bashrc
84-
export CPEM_YAML=https://github.com/equinix/cloud-provider-equinix-metal/releases/download/v3.5.0/deployment.yaml
83+
export CPEM_YAML=https://github.com/equinix/cloud-provider-equinix-metal/releases/download/${CPEM_VERSION:=v3.5.0}/deployment.yaml
8584
export SECRET_DATA='cloud-sa.json=''{"apiKey": "{{ .apiKey }}","projectID": "${PROJECT_ID}", "loadbalancer": "kube-vip://", "facility": "${FACILITY}"}'''
8685
kubectl create secret generic -n kube-system metal-cloud-config --from-literal="$${SECRET_DATA}" || (sleep 1 && kubectl create secret generic -n kube-system metal-cloud-config --from-literal="$${SECRET_DATA}") || (sleep 1 && kubectl create secret generic -n kube-system metal-cloud-config --from-literal="$${SECRET_DATA}")
8786
kubectl apply -f $${CPEM_YAML} || (sleep 1 && kubectl apply -f $${CPEM_YAML}) || (sleep 1 && kubectl apply -f $${CPEM_YAML})

0 commit comments

Comments
 (0)