This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| network_simulation_with_k8s-topo_on_raspi_cluster [2023/09/09 00:59] – created qlyoung | network_simulation_with_k8s-topo_on_raspi_cluster [2024/01/06 05:24] (current) – tags qlyoung | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | This post covers how I set up [k8s-topo](https:// | + | ====== network simulation with k8s-topo on raspberry pi 3b+ cluster ====== |
| + | |||
| + | This post covers how I set up [[https:// | ||
| Here's a picture of the cluster: | Here's a picture of the cluster: | ||
| - |  | (Actually shortly after I wrote this, NSM gained support for Helm 3. I didn't try it since Helm 2 works.) | ||
| - | < | + | < |
| - | wget https:// | + | wget "https:// |
| </ | </ | ||
| Extract the archive and " | Extract the archive and " | ||
| - | < | + | < |
| tar xvzf helm-v2.16.7-linux-arm.tar.gz | tar xvzf helm-v2.16.7-linux-arm.tar.gz | ||
| cp linux-arm/ | cp linux-arm/ | ||
| Line 92: | Line 90: | ||
| The Helm client is now installed. Next step is to install the backend, called '' | The Helm client is now installed. Next step is to install the backend, called '' | ||
| - | < | + | < |
| kubectl -n kube-system create serviceaccount tiller | kubectl -n kube-system create serviceaccount tiller | ||
| Line 101: | Line 99: | ||
| References: | References: | ||
| - | * <https:// | + | |
| - | * <https:// | + | * https:// |
| Now we start getting to the x86 monoculture stuff. | Now we start getting to the x86 monoculture stuff. | ||
| Line 108: | Line 106: | ||
| The backend for Helm, '' | The backend for Helm, '' | ||
| - | Fortunately, | + | Fortunately, |
| To initialize Helm with an appropriate backend image: | To initialize Helm with an appropriate backend image: | ||
| - | < | + | < |
| helm init --service-account tiller --tiller-image=jessestuart/ | helm init --service-account tiller --tiller-image=jessestuart/ | ||
| </ | </ | ||
| - | *Note the tag. If you downloaded a later version of Helm 2 earlier, you'll need to change the tag version to match. The backend version must match the client version (you can see what you installed with '' | + | //Note the tag. If you downloaded a later version of Helm 2 earlier, you'll need to change the tag version to match. The backend version must match the client version (you can see what you installed with '' |
| Next we'll have to build NSM ourselves, because they don't provide images for anything except amd64. | Next we'll have to build NSM ourselves, because they don't provide images for anything except amd64. | ||
| Line 124: | Line 122: | ||
| Install Go 1.13: | Install Go 1.13: | ||
| - | < | + | < |
| - | wget https:// | + | wget "https:// |
| tar -C /usr/local -xzf ./ | tar -C /usr/local -xzf ./ | ||
| export PATH=$PATH:/ | export PATH=$PATH:/ | ||
| Line 132: | Line 130: | ||
| Clone the NSM repo: | Clone the NSM repo: | ||
| - | < | + | < |
| git clone https:// | git clone https:// | ||
| cd networkservicemesh | cd networkservicemesh | ||
| Line 139: | Line 137: | ||
| NSM has two forwarding plane implementations available. One is based on VPP (the default), the other uses the kernel. The VPP image, naturally, doesn' | NSM has two forwarding plane implementations available. One is based on VPP (the default), the other uses the kernel. The VPP image, naturally, doesn' | ||
| - | < | + | < |
| root@clusterpi-master:/ | root@clusterpi-master:/ | ||
| IMAGE_TAG= ./ | IMAGE_TAG= ./ | ||
| Line 155: | Line 153: | ||
| Patch 1: | Patch 1: | ||
| - | <code>diff | + | <code diff> |
| diff --git a/ | diff --git a/ | ||
| index 0d24b89f..23c1cac4 100644 | index 0d24b89f..23c1cac4 100644 | ||
| Line 170: | Line 168: | ||
| Patch 2: | Patch 2: | ||
| - | <code>diff | + | <code diff> |
| diff --git a/ | diff --git a/ | ||
| index 97354fbf..d1aff0d3 100644 | index 97354fbf..d1aff0d3 100644 | ||
| Line 185: | Line 183: | ||
| At this point we can build the project. This takes about an hour on my Pi 3B+. | At this point we can build the project. This takes about an hour on my Pi 3B+. | ||
| - | < | + | < |
| make k8s-build | make k8s-build | ||
| </ | </ | ||
| Line 191: | Line 189: | ||
| In order to work around some other stuff, we'll need raw tarballs of the Docker images we just built. There' | In order to work around some other stuff, we'll need raw tarballs of the Docker images we just built. There' | ||
| - | < | + | < |
| make k8s-save | make k8s-save | ||
| </ | </ | ||
| - | Your built images are now in your local docker registry, | + | Your built images are now in your local docker registry, **but k3s doesn' |
| In case you already did this by mistake, you'll need to log into each node and run the following to delete the amd64 images from the cache: | In case you already did this by mistake, you'll need to log into each node and run the following to delete the amd64 images from the cache: | ||
| - | < | + | < |
| k3s ctr images list | grep networkservicemesh | cut -d' ' -f1 | xargs k3s ctr images remove | k3s ctr images list | grep networkservicemesh | cut -d' ' -f1 | xargs k3s ctr images remove | ||
| </ | </ | ||
| Line 207: | Line 205: | ||
| You could also create a local registry and serve your images from there; I tried this, ran into some TLS issues, canned it. | You could also create a local registry and serve your images from there; I tried this, ran into some TLS issues, canned it. | ||
| - | *Hacky way* | + | **Hacky way** |
| All the images you saved in '' | All the images you saved in '' | ||
| Line 215: | Line 213: | ||
| - Run this: | - Run this: | ||
| - | | + | < |
| - | for file in ./*; do k3s ctr images import $file; done | + | for file in ./*; do k3s ctr images import $file; done |
| - | </ | + | </ |
| Note you'll have to do this for other images later on, so it's probably better to just use DockerHub. | Note you'll have to do this for other images later on, so it's probably better to just use DockerHub. | ||
| - | *Correct Way* | + | **Correct Way** |
| Retag your built images and push them to your personal DockerHub repository. | Retag your built images and push them to your personal DockerHub repository. | ||
| Line 227: | Line 225: | ||
| Now, at last, you can deploy NSM: | Now, at last, you can deploy NSM: | ||
| - | < | + | < |
| SPIRE_ENABLED=false INSECURE=true FORWARDING_PLANE=kernel make helm-install-nsm | SPIRE_ENABLED=false INSECURE=true FORWARDING_PLANE=kernel make helm-install-nsm | ||
| </ | </ | ||
| - | At this point the containers deployed successfully, | + | At this point the containers deployed successfully, |
| By this time '' | By this time '' | ||
| Line 241: | Line 239: | ||
| Instead of NSM I ended up going with '' | Instead of NSM I ended up going with '' | ||
| - | #### Setting up meshnet-cni | + | === Setting up meshnet-cni |
| Just like with NetworkServiceMesh, | Just like with NetworkServiceMesh, | ||
| - | < | + | < |
| git clone --single-branch --branch k3s-arm https:// | git clone --single-branch --branch k3s-arm https:// | ||
| </ | </ | ||
| Brief summary of changes made: | Brief summary of changes made: | ||
| - | - Change all binary downloads to fetch ARM versions | + | * Change all binary downloads to fetch ARM versions |
| - | - Modify CNI config files for k3s Flannel | + | |
| - | - Remove node selectors that restrict to amd64 nodes | + | |
| - | - Change docker images to point at ARM-compatible builds with above changes | + | |
| - | - Modify CNI config paths to place them in the custom k3s locations | + | |
| The last one does require some manual patching. k3s does not use the standard ''/ | The last one does require some manual patching. k3s does not use the standard ''/ | ||
| Line 262: | Line 260: | ||
| To find the GUID: | To find the GUID: | ||
| - | < | + | < |
| ls / | ls / | ||
| </ | </ | ||
| Line 268: | Line 266: | ||
| There should be a single directory there whose name is a long hash-looking string, in my case: | There should be a single directory there whose name is a long hash-looking string, in my case: | ||
| - | < | + | < |
| # ls / | # ls / | ||
| ec54df8c1938fe49660230d16334b4c7e83888a93e6f037fd8552893e2f67383/ | ec54df8c1938fe49660230d16334b4c7e83888a93e6f037fd8552893e2f67383/ | ||
| Line 275: | Line 273: | ||
| To make sure '' | To make sure '' | ||
| - | < | + | < |
| export K3S_CNI_GUID=< | export K3S_CNI_GUID=< | ||
| sed -i -e " | sed -i -e " | ||
| Line 282: | Line 280: | ||
| Now you should be ready to deploy '' | Now you should be ready to deploy '' | ||
| - | < | + | < |
| apt install -yqq build-essential | apt install -yqq build-essential | ||
| make install | make install | ||
| Line 289: | Line 287: | ||
| If the installation was successful you should now have a '' | If the installation was successful you should now have a '' | ||
| - | < | + | < |
| # kubectl -n meshnet get all | # kubectl -n meshnet get all | ||
| NAME READY | NAME READY | ||
| Line 303: | Line 301: | ||
| With luck you should be good to go, and '' | With luck you should be good to go, and '' | ||
| - | ### Step 2 - Disable load balancer | + | === Step 2 - Disable load balancer |
| Now that we have our overlay ('' | Now that we have our overlay ('' | ||
| Line 317: | Line 314: | ||
| Anyway, we need to turn that off: | Anyway, we need to turn that off: | ||
| - | <https:// | + | [[https:// |
| - | <https:// | + | [[https:// |
| Copied here for posterity: | Copied here for posterity: | ||
| Line 353: | Line 350: | ||
| And finally, we can deploy '' | And finally, we can deploy '' | ||
| - | ### Step 3 - Install k8s-topo | + | === Step 3 - Install k8s-topo |
| Now that we have our overlay ('' | Now that we have our overlay ('' | ||
| Line 361: | Line 358: | ||
| Pull my ARM-compatible fork of '' | Pull my ARM-compatible fork of '' | ||
| - | < | + | < |
| git clone --single-branch --branch k3s-arm https:// | git clone --single-branch --branch k3s-arm https:// | ||
| </ | </ | ||
| - | One notable change is that I've also added support for [FRR](https:// | + | One notable change is that I've also added support for [[https:// |
| Now you can deploy '' | Now you can deploy '' | ||
| - | < | + | < |
| cd k8s-topo | cd k8s-topo | ||
| kubectl apply -f manifest.yml | kubectl apply -f manifest.yml | ||
| Line 378: | Line 375: | ||
| Verify that the '' | Verify that the '' | ||
| - | < | + | < |
| root@clusterpi-69 # kubectl get all | root@clusterpi-69 # kubectl get all | ||
| NAME READY | NAME READY | ||
| Line 396: | Line 393: | ||
| That's it, we're done! | That's it, we're done! | ||
| - | ### Step 4 - profit | + | === Step 4 - profit |
| Now you can log into the '' | Now you can log into the '' | ||
| - | < | + | < |
| root@clusterpi-69 # kubectl exec -it deployment/ | root@clusterpi-69 # kubectl exec -it deployment/ | ||
| Line 428: | Line 425: | ||
| </ | </ | ||
| - | ### Usage Examples | + | === Usage Examples |
| Create a random FRR topology: | Create a random FRR topology: | ||
| - | < | + | < |
| /k8s-topo # cd examples/ | /k8s-topo # cd examples/ | ||
| / | / | ||
| Line 485: | Line 482: | ||
| Apply the topology: | Apply the topology: | ||
| - | < | + | < |
| / | / | ||
| /k8s-topo # k8s-topo --create examples/ | /k8s-topo # k8s-topo --create examples/ | ||
| Line 505: | Line 502: | ||
| Log out of the container and verify that the pods have been created: | Log out of the container and verify that the pods have been created: | ||
| - | < | + | < |
| root@clusterpi-69 # kubectl get all | root@clusterpi-69 # kubectl get all | ||
| NAME READY | NAME READY | ||
| Line 524: | Line 521: | ||
| < | < | ||
| root@clusterpi-69 # kubectl exec -it pod/ | root@clusterpi-69 # kubectl exec -it pod/ | ||
| - | / # ip addr | + | # ip addr |
| 1: lo: < | 1: lo: < | ||
| link/ | link/ | ||
| Line 549: | Line 546: | ||
| inet6 fe80:: | inet6 fe80:: | ||
| | | ||
| - | / # vtysh | + | # vtysh |
| % Can't open configuration file / | % Can't open configuration file / | ||
| Line 574: | Line 571: | ||
| Welcome to your simulation. | Welcome to your simulation. | ||
| - | ### Notes | + | === Notes === |
| I've extensively replaced various components of this setup with my own forks to which I've added ARM support. I plan to merge the ARM changes back into their respective upstream repos, but this is going to take some time, as the changes I've done currently are very quick-and-dirty. They need to be rewritten not just to work on ARM, but to generalize amd64-specific build options to work on any target architecture. | I've extensively replaced various components of this setup with my own forks to which I've added ARM support. I plan to merge the ARM changes back into their respective upstream repos, but this is going to take some time, as the changes I've done currently are very quick-and-dirty. They need to be rewritten not just to work on ARM, but to generalize amd64-specific build options to work on any target architecture. | ||
| I very much dislike making this setup depending on my personal GitHub forks and DockerHub registry, but doing so was the only way I could finish this project in a reasonable time frame. | I very much dislike making this setup depending on my personal GitHub forks and DockerHub registry, but doing so was the only way I could finish this project in a reasonable time frame. | ||
| + | |||
| + | {{tag> | ||
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International