Skip to content

Commit ca5c41d

Browse files
fix(post): Added cloud-init section
1 parent 36ade8f commit ca5c41d

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

_posts/2024-04-14-advanced-kubernetes-networking.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,70 @@ k8s-home-worker-03 Ready worker 5d v1.28.8+rke2r1
426426

427427
You can see more flags on the [RKE2 documentation page](https://docs.rke2.io/reference/linux_agent_config)
428428

429+
### cloud-init and routing
430+
431+
I have also seen odd issues when with routing and using cloud init. I've had to override some settings using `netplan`
432+
433+
You can see there is a misplaced route in your tables
434+
435+
```bash
436+
➜ ~ ip route
437+
192.168.20.0/24 dev eth1 proto kernel scope link src 192.168.20.72 metric 100
438+
192.168.20.1 dev eth1 proto dhcp scope link src 192.168.20.72 metric 100
439+
192.168.60.0/24 dev eth0 proto kernel scope link src 192.168.60.55 metric 100
440+
192.168.60.1 dev eth0 proto dhcp scope link src 192.168.60.55 metric 100
441+
192.168.60.10 via 192.168.20.1 dev eth1 proto dhcp src 192.168.20.72 metric 100 # wrong
442+
192.168.60.10 dev eth0 proto dhcp scope link src 192.168.60.55 metric 100
443+
192.168.60.22 via 192.168.20.1 dev eth1 proto dhcp src 192.168.20.72 metric 100 #wrong
444+
192.168.60.22 dev eth0 proto dhcp scope link src 192.168.60.55 metric 100
445+
```
446+
447+
To fix this, we need to override the routes with `netplan`
448+
449+
```bash
450+
sudo nano /etc/netplan/50-cloud-init.yaml
451+
```
452+
453+
```yaml
454+
# This file is generated from information provided by the datasource. Changes
455+
# to it will not persist across an instance reboot. To disable cloud-init's
456+
# network configuration capabilities, write a file
457+
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
458+
# network: {config: disabled}
459+
network:
460+
version: 2
461+
ethernets:
462+
eth0:
463+
dhcp4: true
464+
match:
465+
macaddress: bc:25:12:26:27:7d
466+
set-name: eth0
467+
routes:
468+
- to: 0.0.0.0/0
469+
via: 192.168.60.1
470+
metric: 100
471+
dhcp4-overrides:
472+
use-dns: false # Disable DNS from DHCP
473+
nameservers:
474+
addresses: [192.168.60.10, 192.168.60.22] # DNS servers for eth0
475+
476+
eth1:
477+
dhcp4: true
478+
match:
479+
macaddress: bc:27:21:b1:4b:37
480+
set-name: eth1
481+
routes:
482+
- to: 0.0.0.0/0
483+
via: 192.168.20.1
484+
metric: 101
485+
dhcp4-overrides:
486+
use-dns: false # Disable DNS from DHCP
487+
nameservers:
488+
addresses: [192.168.60.10, 192.168.60.22] # DNS servers for eth1
489+
```
490+
491+
If you know of a better way to do this, please let me know in the comments.
492+
429493
## Join the conversation
430494

431495
<blockquote class="twitter-tweet" data-dnt="true" data-theme="dark"><p lang="en" dir="ltr">Today I released 40 minute, super niche technical video on advanced Kubernetes networking with Multus. <br><br>I didn&#39;t do it for the algorithm, I did it because I loved every minute of it. (Well, after I got it working)<a href="https://t.co/O7sLjDIMXt">https://t.co/O7sLjDIMXt</a> <a href="https://t.co/bBnBbmlsDx">pic.twitter.com/bBnBbmlsDx</a></p>&mdash; Techno Tim (@TechnoTimLive) <a href="https://twitter.com/TechnoTimLive/status/1779516238533627905?ref_src=twsrc%5Etfw">April 14, 2024</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

0 commit comments

Comments
 (0)