Kubernetes CKA sample exam question 98 with answer

Question
Deploy an Ingress resource called multi-host-ingress with following configuration:

backend path: /video
backend service: web-service
backend port: 8080
hostname: web.example.com
backend path: /
backend service: search-service
backend port: 9000
hostname: search.example.com
Answer
This is an example of multi hosts support with Ingress resource. You can specify different hostname and map them with specific backend services. This is what you definitely work on in real world scenarios:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: multi-host-ingress
spec:
  rules:
  - host: "web.example.com"
    http:
      paths:
      - pathType: Prefix
        path: "/video"
        backend:
          service:
            name: web-service
            port:
              number: 8080
  - host: "search.example.com"
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: search-service
            port:
              number: 9000
Apply and verify:
kubectl apply -f i.yaml
kubectl describe ingress multi-host-ingress