Welcome to the Linux Foundation Forum!

lab 11.2 ingress balancing and not routing based on host header

Options
Posts: 2
edited June 23 in LFS258 Class Forum

I've got an issue where after i've setup lab 11.2 ingress with two nginx pods and the corresponding ingress controllers and ingress rules etc. despite curling to load-balancer IP using the host header, they traffic is always balanced between the two, the host header seems to be ignored.

kubectl get pods NAME READY STATUS RESTARTS AGE myingress-ingress-nginx-controller-2jwkw 2/2 Running 281 (3d23h ago) 5d myingress-ingress-nginx-controller-bjbh9 2/2 Running 0 3d23h nfs-subdir-external-provisioner-6b958d8dd5-fqt4z 1/1 Running 16 (3d23h ago) 68d web-one-6bd47f96d7-5przs 1/1 Running 0 5d2h web-two-6bd47f96d7-4bchp 1/1 Running 1 (3d23h ago) 5d2h

kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 84d myingress-ingress-nginx-controller LoadBalancer 10.100.109.123 <pending> 80:31751/TCP,443:31047/TCP 10d myingress-ingress-nginx-controller-admission ClusterIP 10.97.128.57 <none> 443/TCP 10d web-one ClusterIP 10.102.13.165 <none> 80/TCP 72m web-two ClusterIP 10.104.211.198 <none> 80/TCP 71

kubectl get ingress -o yaml
apiVersion: v1
items:

  • apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
    annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/service-upstream: "true"
    creationTimestamp: "2025-06-18T20:01:34Z"
    generation: 2
    name: ingress-test
    namespace: default
    resourceVersion: "5609621"
    uid: d48f43a7-097b-41cb-ba4d-742f880649bc
    spec:
    ingressClassName: nginx
    rules:
    • host: www.internal.com
      http:
      paths:
      • backend:
        service:
        name: web-two
        port:
        number: 80
        path: /
        pathType: ImplementationSpecific
    • host: www.external.com
      http:
      paths:
      • backend:
        service:
        name: web-one
        port:
        number: 80
        path: /
        pathType: ImplementationSpecific
        status:
        loadBalancer: {}
        kind: List
        metadata:
        resourceVersion: ""

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • Posts: 2,467

    Hi @dsfraser,

    Are the two applications web-one and web-two distinct? Do they return different content when accessed individually, and you can tell for sure which application was accessed based on its returned response?

    Regards,
    -Chris

  • Posts: 2
    edited June 24

    Thanks for the reply chris, they are both nginx web servers and as per the instructions I have adjusted the index.html file to state either EXTERNAL or INTERNAL, but what happens is if I curl to external for example I get both INTERNAL And EXTERNAL output, it's like it's ignoring the host header and just balancing.

    root@master1:~# curl -H "Host: www.external.com" http://10.100.109.123
    <!DOCTYPE html>


    Welcome to INTERNAL!

    root@master1:~# curl -H "Host: www.external.com" http://10.100.109.123
    <!DOCTYPE html>


    Welcome to EXTERNAL!

    -Sam Fraser

  • Posts: 2,467

    Hi @dsfraser,

    Please provide the outputs for the following commands, using the code formatting for readability:

    1. kubectl get pod,svc,ep -o wide
    2. kubectl get ingress
    3. kubectl describe ingress ingress-test

    Regards,
    -Chris

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training