I have one question which I couldn't find a clear explaination.
If I have a service :
apiVersion: v1
kind: Service
metadata:
name: my-app-svc
namespace: myns
spec:
type: LoadBalancer
ports:
- name: http
port: 8080
targetPort: 8282
selector:
app: my-app
As you can see above, I explicitly declared type: LoadBalancer
. I understand what it means. I am using AWS EKS. I wonder from traffic perspective, does it mean the incoming http traffic flow is :
Load Balancer --> Node port --> service port(8080) --> Pod port(8282)
Or:
Load Balancer --> service port(8080) --> Pod port(8282)
Which one is correct? If neither is correct, what would be the traffic flow in terms of the order in which each k8s component is involved?
Load Balancer --> Node port --> service port(8080) --> Pod port(8282)
Your diagram is correct for instance mode:
Traffic reaching the ALB is routed to NodePort for your service and then proxied to your pods. This is the default traffic mode.
There is an option of using IP mode where you have AWS LB Controller installed and set alb.ingress.kubernetes.io/target-type: ip
:
Traffic reaching the ALB is directly routed to pods for your service.
More details can be found here.