Skip to content

Commit

Permalink
Using bash/shell script to patch to make thing reabable and fix issue…
Browse files Browse the repository at this point in the history
… with makefile patches
  • Loading branch information
komer3 committed Jan 10, 2025
1 parent 6190572 commit 4c3ef44
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 45 deletions.
48 changes: 3 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,51 +197,9 @@ e2e-test:

.PHONY: e2e-test-bgp
e2e-test-bgp:
# Debugging: Print the nodes in the cluster
KUBECONFIG=$(KUBECONFIG_PATH) kubectl get nodes -o wide
KUBECONFIG=$(KUBECONFIG_PATH) kubectl get nodes --no-headers |\
grep -v control-plane | awk '{print $$1}'

# Add bgp peering label to non control plane nodes
KUBECONFIG=$(KUBECONFIG_PATH) kubectl get nodes --no-headers | grep -v control-plane |\
awk '{print $$1}' | xargs -I {} env KUBECONFIG=$(KUBECONFIG_PATH) kubectl label nodes {} cilium-bgp-peering=true --overwrite

# First patch: Add the necessary RBAC permissions
KUBECONFIG=$(KUBECONFIG_PATH) kubectl patch clusterrole ccm-linode-clusterrole \
--type='json' \
-p='[\
{\
"op": "add",\
"path": "/rules/-",\
"value": {\
"apiGroups": ["cilium.io"],\
"resources": ["ciliumloadbalancerippools", "ciliumbgppeeringpolicies"],\
"verbs": ["get", "list", "watch", "create", "update", "patch", "delete"]\
}\
}\
]'

# Patch: Append new args to the existing ones
KUBECONFIG=$(KUBECONFIG_PATH) kubectl patch daemonset ccm-linode -n kube-system \
--type='json' \
-p='[\
{\
"op": "add",\
"path": "/spec/template/spec/containers/0/args/-",\
"value": "--bgp-node-selector=cilium-bgp-peering=true"\
},\
{\
"op": "add",\
"path": "/spec/template/spec/containers/0/args/-",\
"value": "--load-balancer-type=cilium-bgp"\
},\
{\
"op": "add",\
"path": "/spec/template/spec/containers/0/args/-",\
"value": "--ip-holder-suffix=ccm-8039dcf"\
}\
]'

# Setup Cilium BGP peering
KUBECONFIG=$(KUBECONFIG_PATH) CLUSTER_SUFFIX=$(CLUSTER_NAME) ./e2e/setup/cilium-setup.sh

# Wait for rollout
KUBECONFIG=$(KUBECONFIG_PATH) kubectl -n kube-system rollout status daemonset/ccm-linode --timeout=300s

Expand Down
32 changes: 32 additions & 0 deletions e2e/setup/cilium-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -euo pipefail

# Add bgp peering label to non control plane nodes
kubectl get nodes --no-headers | grep -v control-plane |\
awk '{print $1}' | xargs -I {} kubectl label nodes {} cilium-bgp-peering=true --overwrite

# Add RBAC permissions
kubectl patch clusterrole ccm-linode-clusterrole --type='json' -p='[{
"op": "add",
"path": "/rules/-",
"value": {
"apiGroups": ["cilium.io"],
"resources": ["ciliumloadbalancerippools", "ciliumbgppeeringpolicies"],
"verbs": ["get", "list", "watch", "create", "update", "patch", "delete"]
}
}]'

# Patch DaemonSet
kubectl patch daemonset ccm-linode -n kube-system --type='json' -p='[{
"op": "add",
"path": "/spec/template/spec/containers/0/args/-",
"value": "--bgp-node-selector=cilium-bgp-peering=true"
}, {
"op": "add",
"path": "/spec/template/spec/containers/0/args/-",
"value": "--load-balancer-type=cilium-bgp"
}, {
"op": "add",
"path": "/spec/template/spec/containers/0/args/-",
"value": "--ip-holder-suffix='"${CLUSTER_SUFFIX}"'"
}]'

0 comments on commit 4c3ef44

Please sign in to comment.