-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to use internal node IPs for NodePort services #10278
Conversation
Hello @jorisvergeer, Thanks for opening this! We took a look at the changes and discussed the feature and we have some feedback. We may need to discuss further the initial behavior or say the handling of NodePort services by Traefik in a proposal issue. We also noticed that the new behavior is implemented only for the Kubernetes CRD provider, but it should also be available for the Kubernetes Ingress provider, could you please address that in your PR? As a first-glance, review comment, we also noticed that in the Kubernetes client, it uses the service namespace to fetch node resources, but as nodes are not namespaced, this should not be the case. |
Hi @rtribotte , I am trying to implement your suggestions. I think I got the "nodePortLB" working in the CRD in the code. But if I search in the repo for "nativeLB" it comes up at hundreds of places, and also in other route types, like UDP and TCP route kinds. Also there are lots of copies of the CRD definition schema's where nativeLB is mentioned as well. I'd like some guidance to where I can limit the scope of this PR. |
Hello @jorisvergeer, Sure, for CRD manifests:
you need to run For the documentation ( |
c97cc14
to
3d01fc2
Compare
Before applying changes, the PR should be rebased on the branch v3.0 because the PR is based on v2.10 branch. $ git remote -v
origin git@github.com:jorisvergeer/traefik.git (fetch)
origin git@github.com:jorisvergeer/traefik.git (push)
upstream git@github.com:traefik/traefik.git (fetch)
upstream git@github.com:traefik/traefik.git (push)
$ fetch --multiple upstream origin
...
$ git switch feature_node_port_ip
...
$ git rebase --onto=upstream/v3.0 dae0491b6
...
# The conflicts should be fixed. |
60fae39
to
0d0bd05
Compare
Sorry, for the changing branches a bit. I was testing changes based on 2.11 and 3.0 locally. I merged my changes, originally build on 2.10 with 3.0 now. I think the code is finished, currently testing it in my test environment. Expecting it to pass in the next hour or so. |
@rtribotte @ldez |
Due to the multiple branch changes the CI is lost, I should close and re-open the PR. Note: I recommend using |
I see that I have to work on the unit tests. |
the problem is not unit tests but the code because the code of v2 is not the same as the v3 https://github.com/traefik/traefik/actions/runs/7788029566/job/21236555014?pr=10278 |
That's what i meant. The mocked GetNodes got lost i think. |
Fixed locally, and took the liberty to add unit tests for NodePortLB as well. Some unrelated docker unit tests failed locally. Not sure if that's a problem with my code. |
(cherry picked from commit c97cc14)
Fix lint
2cf5b16
to
e73e176
Compare
Hi Guys this is not included in 3.0, any plans to add this to any version? |
@deveshk0 It's merged into master so it should be available in 3.1 |
What does this PR do?
This PR causes traefik to use the ip adresses of the node insead of the pods when kubernetes services are of type NodePort. In this case it also uses the services nodePort instead of the port.
Motivation
I have a mixed cloud environment with some micro services running in k8s and some not. I run traefik externally in a separate instance. Using the kubernetesCRD provider, treafik is able to detect the services. The only problem is that the IP addresses that are detected are the internal pod ip adresses. And those are not accessible from the instance running traefik.
The services are accessible from the node ip when the service type is NodePort. In this case traefik should be able to access the services using the node ip and the nodeport of the service.
This feature would help me to assist in a gradual migration from native services to traefik and k8s.
More
Additional Notes
This might have impact on users that accidently (or purposely) use nodeport as service type.
Is this a feature that will even be considered?
Can this feature also be merged into the 2.x branch?