mmumshad / kubernetes-the-hard-way

Bootstrap Kubernetes the hard way on Vagrant on Local Machine. No scripts.
Apache License 2.0
4.72k stars 4.56k forks source link

[Bug]: sysctl: setting key "net.ipv4.conf.all.accept_source_route": Invalid argument and sysctl: setting key "net.ipv4.conf.all.promote_secondaries": Invalid argument during the hosts setup #343

Open adrianolw opened 4 months ago

adrianolw commented 4 months ago

Your Workstation

Windows (10 or 11)

System Memory

16GB or more

What happened?

Running the Vagrant up I got this messages:

    node02: net.ipv4.conf.default.accept_source_route = 0
    node02: sysctl: setting key "net.ipv4.conf.all.accept_source_route": Invalid argument
    node02: net.ipv4.conf.default.promote_secondaries = 1
    node02: sysctl: setting key "net.ipv4.conf.all.promote_secondaries": Invalid argument

I'm using the jammy64 version. After finnish the lab, I run a nginx test deploy, pod, and installed a Nginx IngressController and tried to use with some pathprefix but nothing is working, and I discovered that my POD is not accessible from other hosts like controlplane or other node then the node that is running the pod. I tested the WeaveNet and Flannel as well, but nothing changed.

vagrant@controlplane01:~$ k get pods -n teste-nginx -o wide
NAME                     READY   STATUS    RESTARTS   AGE   IP           NODE     NOMINATED NODE   READINESS GATES
deploy-576c6b7b6-smzgb   1/1     Running   0          21h   10.244.0.2   node01   <none>           <none>
vagrant@controlplane01:~$ 

Check the curl on controlplane:

vagrant@controlplane01:~$ curl -i http://10.244.0.2
curl: (28) Failed to connect to 10.244.0.2 port 80 after 130826 ms: Connection timed out

Test directly on node01

 vagrant@node01:~$ curl -i http://10.244.0.2
HTTP/1.1 200 OK
Server: nginx/1.27.0
Date: Sun, 07 Jul 2024 23:28:35 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Tue, 28 May 2024 13:22:30 GMT
Connection: keep-alive
ETag: "6655da96-267"
Accept-Ranges: bytes

And of course with that my ingress rule is not working, I just got a 404 HTTP error.

I think that could be related to the two parameters that I mention on the subject, can someone help me ?

Relevant output

No response

scottishwidow commented 2 months ago

Changing to Bionic Beaver helped, though no idea how to fix it on Jammy.

fireflycons commented 2 months ago

Hi @adrianolw curl -i http://10.244.0.2 is incorrect.

You are trying to access the pod network directly from the virtual machine. There is no route for that.

You should have either

  1. Create a nodeport service for the deployment and attempt to curl the nodeport on 127.0.0.1:<node port>
  2. Run another pod that has curl inside, do kubectl exec to that pod and run the above curl inside the test pod
  3. Use kubectl port-forward to the deployment's pod, and in another ssh shell, curl the forwarded port on 127.0.0.1:<forwarded port>

These techniques are all discussed in CKA course material.