Complete the code to specify the host for routing in the Ingress rule.
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example-ingress spec: rules: - host: [1] http: paths: - path: / pathType: Prefix backend: service: name: example-service port: number: 80
The host field specifies the domain name for host-based routing in the Ingress rule.
Complete the code to specify the path type for host-based routing.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
spec:
rules:
- host: example.com
http:
paths:
- path: /app
pathType: [1]
backend:
service:
name: app-service
port:
number: 80The pathType defines how the path is matched. Prefix means any path starting with /app will match.
Fix the error in the Ingress rule to correctly specify the backend service port.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
spec:
rules:
- host: example.com
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: api-service
port:
[1]The port field must be an object with a number key specifying the port number.
Fill both blanks to create a host-based routing rule for two different hosts.
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: multi-host-ingress spec: rules: - host: [1] http: paths: - path: / pathType: Prefix backend: service: name: service-one port: number: 80 - host: [2] http: paths: - path: / pathType: Prefix backend: service: name: service-two port: number: 80
Each host field must have a unique domain name for routing to different services.
Fill all three blanks to define an Ingress with host-based routing, path, and backend service port.
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: full-ingress spec: rules: - host: [1] http: paths: - path: [2] pathType: Prefix backend: service: name: full-service port: number: [3]
The host is the domain name, path is the URL path prefix, and number is the backend service port.