Skip to content
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

How can inbound traffic be routed exclusively to the current node's Traefik pod? #63

Open
Arc-2023 opened this issue Jan 7, 2024 · 2 comments

Comments

@Arc-2023
Copy link

Arc-2023 commented Jan 7, 2024

Currently, I have the following requirements:
Two nodes: node1 and node2
Services are running on node1, and Traefik's pod is running on node2, both with serviceLB enabled.
I want to achieve: when traffic passes through node1 or node2, I want the Traefik on the current node to exclusively handle inbound traffic on that node, rather than on other nodes (if there is no Traefik pod scheduled to the current node, the request should result in an error).
However, when both nodes have Traefik and serviceLB enabled, all requests are load-balanced before entering Traefik, and then evenly distributed to each Traefik pod (since the nodes in the cluster are in different networks, this leads to bandwidth and latency issues).
I understand that the service of type LoadBalancer in Kubernetes can specify externaltrafficpolicy and internaltrafficpolicy as Local. However, this still does not solve the problem.

there is the configuration of loadbalancer:

apiVersion: v1
kind: Service
metadata:
  name: traefik
spec:
  type: LoadBalancer
  selector:
    app: traefik
  externalTrafficPolicy: Local
  internalTrafficPolicy: Local
  ports:
    - protocol: TCP
      port: 80
      name: web80
      targetPort: 80
    - protocol: TCP
      port: 443
      name: https
      targetPort: 443
    - protocol: TCP
      port: 21115
      name: hbbs-1
    - protocol: TCP
      port: 21116
      name: hbbs-2
    - protocol: UDP
      port: 21116
      name: hbbs-3
    - protocol: TCP
      port: 21117
      name: hbbr-1
    - protocol: UDP
      port: 3478
      name: derper
@au2001
Copy link

au2001 commented Jan 10, 2024

I want to achieve: when traffic passes through node1 or node2, I want the Traefik on the current node to exclusively handle inbound traffic on that node, rather than on other nodes (if there is no Traefik pod scheduled to the current node, the request should result in an error).

So... no load balancing at all?
What you want is a Service of kind NodePort to expose Traefik directly

@Arc-2023
Copy link
Author

Arc-2023 commented Jan 11, 2024

I want to achieve: when traffic passes through node1 or node2, I want the Traefik on the current node to exclusively handle inbound traffic on that node, rather than on other nodes (if there is no Traefik pod scheduled to the current node, the request should result in an error).

So... no load balancing at all? What you want is a Service of kind NodePort to expose Traefik directly

well, it's not a convinent way to use node port to expose traefik's service.
to this problem, using the giving configuration can make an effect:

externaltrafficpolicy: Cluster
internaltrafficpolicy: Local

from now on, the traffic is only taken by local traefik pod , load balancing is handled by traefik, not serviceLB

i wonder why externaltrafficpolicy should be false, and why does this truth value affect the behavior of internal traffic policy: even if the internal traffic policy is set to local, load balancing still occurs before Traefik?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants