Kubernetes CKA sample exam question 124 with answer

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

Host *.video.example.com
Service video-service
Path /
Port 8080
Host *.web.example.com
Path /
Service web-service
Port 9090
Answer
Ingress supports wildcard hostnames which means you can map wildcard domain. It also supports multiple paths under one host which allows to setup the multiple routing for same host using different path value.
So the answer is:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: wildcard-host-ingress
spec:
  rules:
  - host: "*.video.example.com"
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: video-service
            port:
              number: 8080
  - host: "*.web.example.com"
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: web-service
            port:
              number: 9090