0
0
Kubernetesdevops~20 mins

Path-based routing in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Path-based Routing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of path-based routing Ingress configuration
Given the following Kubernetes Ingress YAML snippet, what will be the backend service receiving traffic for the path /app1?
Kubernetes
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
spec:
  rules:
  - http:
      paths:
      - path: /app1
        pathType: Prefix
        backend:
          service:
            name: service-app1
            port:
              number: 80
      - path: /app2
        pathType: Prefix
        backend:
          service:
            name: service-app2
            port:
              number: 80
Aservice-app1 on port 80
Bservice-app2 on port 80
CDefault backend service
DNo service, returns 404
Attempts:
2 left
💡 Hint
Look at the path and backend service mapping in the Ingress spec.
Configuration
intermediate
1:30remaining
Correct pathType for prefix matching in Ingress
Which pathType value should be used in a Kubernetes Ingress to route all requests starting with /api to a backend service?
APrefix
BRegex
CExact
DImplementationSpecific
Attempts:
2 left
💡 Hint
Consider which pathType matches all paths starting with the given prefix.
Troubleshoot
advanced
2:30remaining
Why does traffic to /app not route correctly?
A user configured this Ingress snippet but traffic to /app returns 404. What is the most likely cause?
Kubernetes
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
spec:
  rules:
  - http:
      paths:
      - path: /app/
        pathType: Exact
        backend:
          service:
            name: app-service
            port:
              number: 80
AService app-service is not running
BUsing pathType Exact with a trailing slash causes mismatch for /app
CIngress controller is not installed
DPort 80 is blocked by firewall
Attempts:
2 left
💡 Hint
Check how Exact pathType matches requests.
🔀 Workflow
advanced
2:00remaining
Order of path matching in Kubernetes Ingress
In which order does Kubernetes Ingress controller evaluate multiple path rules for routing?
A3,1,2,4
B2,1,3,4
C1,2,3,4
D4,3,2,1
Attempts:
2 left
💡 Hint
Think about how more specific paths should be matched before less specific ones.
Best Practice
expert
3:00remaining
Best practice for path-based routing with overlapping paths
You have two Ingress paths: /app and /app/v2. What is the best practice to ensure traffic to /app/v2 goes to the correct backend without conflict?
AUse a single backend for both paths
BUse pathType Exact for both paths
CUse different Ingress resources for each path
DDefine /app/v2 path before /app path in Ingress rules
Attempts:
2 left
💡 Hint
Consider how path matching order affects routing when paths overlap.