0
0
Kubernetesdevops~10 mins

Host-based routing in Kubernetes - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the host for routing in the Ingress rule.

Kubernetes
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
Drag options to blanks, or click blank then click option'
Aexample-service
B80
C/
Dexample.com
Attempts:
3 left
💡 Hint
Common Mistakes
Using the service name instead of the host domain.
Putting the port number in the host field.
2fill in blank
medium

Complete the code to specify the path type for host-based routing.

Kubernetes
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: 80
Drag options to blanks, or click blank then click option'
AExact
BSuffix
CPrefix
DContains
Attempts:
3 left
💡 Hint
Common Mistakes
Using unsupported path types like Suffix or Contains.
Confusing Exact with Prefix.
3fill in blank
hard

Fix the error in the Ingress rule to correctly specify the backend service port.

Kubernetes
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]
Drag options to blanks, or click blank then click option'
Anumber: 80
B80
Cport: 80
Dname: 80
Attempts:
3 left
💡 Hint
Common Mistakes
Using just the port number without the 'number:' key.
Using 'port: 80' directly instead of nested object.
4fill in blank
hard

Fill both blanks to create a host-based routing rule for two different hosts.

Kubernetes
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
Drag options to blanks, or click blank then click option'
Aapp1.example.com
Bapp2.example.com
Cexample.com
Dservice.example.com
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same host for both rules.
Using service names instead of domain names.
5fill in blank
hard

Fill all three blanks to define an Ingress with host-based routing, path, and backend service port.

Kubernetes
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]
Drag options to blanks, or click blank then click option'
Amyapp.example.com
B/dashboard
C8080
D/api
Attempts:
3 left
💡 Hint
Common Mistakes
Using a path without leading slash.
Using a string instead of a number for port.
Confusing host with service name.