Welcome to the Linux Foundation Forum!

Lab 11.2 Why Ingress rule is not working?

Hi!

I'm stuck at step 10 from Lab 11.2.

I've used ingress.yaml config from labs solutions folder:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-test
  namespace: default
spec:
  rules:
  - host: www.external.com
    http:
      paths:
      - backend:
          service:
            name: web-one
            port:
              number: 80
        path: /
        pathType: ImplementationSpecific
status:
  loadBalancer: {}

Applied it successfully:

[14:02]user@ubuntu-vbox-k8s-master[ingress-nginx]$ kubectl get ingress
NAME           CLASS    HOSTS              ADDRESS   PORTS   AGE
ingress-test   <none>   www.external.com             80      11m

And got working web-one service and other:

[14:02]user@ubuntu-vbox-k8s-master[ingress-nginx]$ kubectl get svc
NAME                                           TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
kubernetes                                     ClusterIP      10.96.0.1       <none>        443/TCP                      30d
myingress-ingress-nginx-controller             LoadBalancer   10.100.135.99   <pending>     80:31209/TCP,443:31337/TCP   13m
myingress-ingress-nginx-controller-admission   ClusterIP      10.105.23.218   <none>        443/TCP                      13m
web-one                                        ClusterIP      10.103.23.224   <none>        80/TCP                       7h26m
web-two                                        ClusterIP      10.108.186.93   <none>        80/TCP

Then I tried Curl:

[14:03]user@ubuntu-vbox-k8s-master[ingress-nginx]$ curl 10.100.135.99
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

It was expected, but I've got same for request with header:

[14:04]user@ubuntu-vbox-k8s-master[ingress-nginx]$ curl -H "Host: www.external.com" http://10.100.135.99
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

Could anybody help?
Thanks in advance,

Best Answer

  • chrispokorni
    chrispokorni Posts: 2,349
    edited October 2021 Answer ✓

    Hi @Gim6626,

    As mentioned in an earlier solution, due to recent changes in the Ingress and Controller relationship, an annotation is required on the Ingress resource:

    ...
    metadata:
      annotations:
        kubernetes.io/ingress.class: nginx
      name: ingress-test
    ...
    

    Regards,
    -Chris

Answers

  • Gim6626
    Gim6626 Posts: 27
    edited October 2021

    Step 15 does not work too, but in other way - it just shows fixed nginx page does not matter what header is passed

  • Gim6626
    Gim6626 Posts: 27

    Thank you, it works!

Categories

Upcoming Training