You are right, that's the default behavior of Kubernetes LoadBalancer
services like Nginx Ingress. LoadBalancer
under the hood uses NodePort
service which is exposed on ALL cluster nodes regardless of EKS node group they belong to.
What you should do is to add externalTrafficPolicy: Local
to your Nginx Ingress LoadBalancer
like that (this is just an example):
apiVersion: v1
kind: Service
metadata:
name: example-service
spec:
selector:
app: example
ports:
- port: 8765
targetPort: 9376
externalTrafficPolicy: Local
type: LoadBalancer
Doing that will cause AWS Load Balancer to target only those nodes who actually run Nginx Ingress pods. After that you may want to use Nginx Ingress nodeSelector
to run only on desired EKS node group.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…