kelseyhightower / kubernetes-the-hard-way

Bootstrap Kubernetes the hard way. No scripts.
Apache License 2.0
41.26k stars 14.12k forks source link

fix(smoke-test): dynamically fetch node name for service curl test #811

Open aghilish opened 2 months ago

aghilish commented 2 months ago

Previously, the smoke test assumed the nginx pod would always be scheduled on node-0, which could lead to failures if the pod was placed on a different node. This update fixes that by dynamically fetching the node where the pod is running.

Changes: Updated the smoke test to retrieve the correct node name for the curl request instead of assuming node-0.

elsonrodriguez commented 6 days ago

This is an interesting one. I believe traffic to nodeports on any machine should still forward to a pod on a different machine, but I also saw this behavior in my resulting cluster after finishing the tutorial.

I scaled the replicas to 2, and then this fixed it. I scaled replicas down to 1, and the cluster is still forwarding correctly from both machines.

It looks like there is a missing route. The main difference I saw is that after scaling both machines have a cni-related route added:

node-0:

...
10.200.0.0/24 dev cni0 proto kernel scope link src 10.200.0.1 linkdown 

node-1

...
10.200.1.0/24 dev cni0 proto kernel scope link src 10.200.1.1