DayOne
Journal
Today I Learned

Day 19 - Ingress Question

Question

The Nginx Ingress Controller has been installed.

Create a new Ingress resource called world for domain name world.universe.mine. The domain points to the K8s Node IP via /etc/hosts.

The Ingress resource should have two routes pointing to the existing Services:

http://world.universe.mine:30080/europe/

and

http://world.universe.mine:30080/asia/

Answer

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
    name: world
    namespace: world
spec:
    ingressClassName: nginx
    rules:
    - host: "world.universe.mine"
        http:
        paths:
        - path: /europe
            pathType: Prefix
            backend:
            service:
                name: europe
                port:
                number: 80
        - path: /asia
            pathType: Prefix
            backend:
            service:
                name: asia
                port:
                number: 80

I just learned about ingressClassName. You should put ingressClassName to match whatever output from k get ingressclass.

This statement, The domain points to the K8s Node IP via /etc/hosts means that if you want to see the IP of the domain, you can see on /etc/hosts file.