0
0
Kubernetesdevops~10 mins

Ingress resource definition in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Ingress resource definition
Define Ingress YAML
Apply YAML with kubectl
Kubernetes creates Ingress resource
Ingress Controller watches resource
Ingress Controller configures routing
External requests routed to services
The flow shows how you write an Ingress YAML, apply it, and how the Ingress Controller uses it to route external traffic to services.
Execution Sample
Kubernetes
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: example-service
            port:
              number: 80
This YAML defines an Ingress that routes requests for example.com to the example-service on port 80.
Process Table
StepActionResource StateIngress Controller ReactionResult
1Write Ingress YAMLIngress resource defined but not appliedNo reactionNo routing configured
2kubectl apply ingress.yamlIngress resource created in clusterIngress Controller detects new resourceStarts processing rules
3Ingress Controller reads rulesIngress resource with host example.com and path /Configures routing rules in controllerRoutes external traffic matching example.com to example-service:80
4External request to example.com arrivesIngress resource unchangedIngress Controller routes requestRequest forwarded to example-service on port 80
5Ingress resource deletedIngress resource removedIngress Controller removes routing rulesTraffic no longer routed through Ingress
💡 Ingress resource deleted or no longer exists, so routing stops
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
Ingress Resourceundefineddefined in clusterconfigured with rulesunchangeddeleted
Ingress Controller Stateidledetects resourceconfigures routingroutes trafficremoves routing
Key Moments - 3 Insights
Why doesn't the Ingress route traffic immediately after writing the YAML file?
Because the YAML file is only local until applied with kubectl (see execution_table step 1 and 2). The Ingress Controller reacts only after the resource exists in the cluster.
What happens if the Ingress resource is deleted but the service still exists?
The Ingress Controller removes routing rules (execution_table step 5), so external traffic won't reach the service via Ingress anymore.
How does the Ingress Controller know which service to route traffic to?
It reads the backend service name and port from the Ingress rules (execution_table step 3) and configures routing accordingly.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does the Ingress Controller start configuring routing rules?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Check the 'Ingress Controller Reaction' column in execution_table rows
According to the variable tracker, what is the state of the Ingress Resource after Step 3?
Aconfigured with rules
Bdefined in cluster
Cundefined
Ddeleted
💡 Hint
Look at the 'Ingress Resource' row and 'After Step 3' column in variable_tracker
If the Ingress resource is deleted, what happens to the routing according to the execution table?
ARouting continues as before
BRouting stops because rules are removed
CIngress Controller adds new rules
DService is deleted automatically
💡 Hint
See the 'Result' column at Step 5 in execution_table
Concept Snapshot
Ingress resource defines rules to route external HTTP(S) traffic to Kubernetes services.
Write YAML with apiVersion, kind: Ingress, metadata, and spec.rules.
Apply with kubectl to create resource in cluster.
Ingress Controller watches resource and configures routing.
Deleting Ingress removes routing rules.
Ingress routes based on host and path to backend service and port.
Full Transcript
An Ingress resource in Kubernetes is a set of rules that tell the cluster how to route external web traffic to internal services. First, you write a YAML file defining the Ingress with host and path rules pointing to a service and port. Then you apply this YAML using kubectl, which creates the Ingress resource in the cluster. The Ingress Controller watches for these resources and configures itself to route incoming requests matching the rules to the correct service. When the Ingress resource is deleted, the controller removes the routing rules, stopping traffic from being routed through it. This flow ensures external traffic reaches the right service based on the rules you define.