From df185c88a579fd68b118617ea5f7988d912cc3ad Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Sat, 13 Apr 2019 04:30:22 -0500 Subject: [PATCH] Add shell snippet generating route commands --- slides/k8s/cni.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/slides/k8s/cni.md b/slides/k8s/cni.md index 16ddfeba..319e39d5 100644 --- a/slides/k8s/cni.md +++ b/slides/k8s/cni.md @@ -499,6 +499,32 @@ What does that mean? --- +class: extra-details + +## Other ways to distribute routing tables + +- We don't need kube-router and BGP to distribute routes + +- The list of nodes (and associated `podCIDR` subnets) is available through the API + +- This shell snippet generates the commands to add all required routes on a node: + +```bash +NODES=$(kubectl get nodes -o name | cut -d/ -f2) +for DESTNODE in $NODES; do + if [ "$DESTNODE" != "$HOSTNAME" ]; then + echo $(kubectl get node $DESTNODE -o go-template=" + route add -net {{.spec.podCIDR}} gw {{(index .status.addresses 0).address}}") + fi +done +``` + +- This could be useful for embedded platforms with very limited resources + + (or lab environments for learning purposes) + +--- + # Interconnecting clusters - We assigned different Cluster CIDRs to each cluster