How to Troubleshoot a Kubernetes Ingress Configuration
The DevOps team is preparing a front-end application for a test environment. The application and its Service have already been deploy in the frontend-app namespace, but users are unable to access the application through its configured hostname.
Apply the provided manifest for frontend-app :
kubectl apply -f https://raw.githubusercontent.com/techiescamp/cka-certification-guide/main/ingress/scenarios/frontend.yamlAn Ingress manifest has been provided in frontend-ing.yaml. The Ingress contains configuration errors that prevent traffic from being routed correctly to the front-end application.frontend-ing.yaml manifest:
apiVersion: networking.k8s.io/v2
kind: Inrgess
metadata:
name: frontend-ingress
spec:
rules:
- host: frontend.devopscube.com/
http:
paths:
- path: /*
pathType: Inherit
backend:
service:
name: nginx-svc
port:
number: 3080Your task is to troubleshoot the Ingress configuration and make the application accessible through frontend.devopscube.com
First, verify that the existing application and Service in the frontend-app namespace are running correctly.
Then inspect the provided Ingress manifest, identify the configuration errors, and correct them. Deploy the corrected Ingress and verify that it successfully routes requests to the front-end Service.
The application should be accessible through the Ingress hostname and return the expected front-end application response.
Use the Ingress controller's ClusterIP with curl and DNS/Host-header simulation to validate the configuration.
Ensure the Kubernetes NGINX Ingress controller is available in the cluster before testing the final configuration.
Apply the provided manifest for Kubernetes NGINX Ingress controller :
kubectl apply -f https://raw.githubusercontent.com/techiescamp/cka-certification-guide/main/ingress/nginx-controller.yamlDeploy the Application and Service
Apply the provided manifest to create the front-end application and Service in the frontend-app namespace:
$ kubectl apply -f https://raw.githubusercontent.com/techiescamp/cka-certification-guide/main/ingress/scenarios/frontend.yaml
namespace/frontend-app created
configmap/nginx-index created
deployment.apps/nginx-app created
service/nginx-service createdVerify the Application
Check the Pods to confirm that the application is running:
$ kubectl get pods -n frontend-app
NAME READY STATUS RESTARTS AGE
nginx-app-8975bbbb6-2vx2r 1/1 Running 0 9sThe application Pod should show STATUS: Running and READY: 1/1.
Then verify the Service:
$ kubectl get svc -n frontend-app
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx-service ClusterIP 10.103.46.96 <none> 80/TCP 17sYou should find nginx-service exposing port 80.
Create the Problematic Ingress
Create a file named frontend-ing.yaml and add the intentionally incorrect Ingress configuration. Then apply the manifest using kubectl apply and carefully review the error returned by Kubernetes. This helps you identify the configuration issues before making the required corrections.
$ kubectl apply -f frontend-ing.yaml
error: resource mapping not found for name: "frontend-ingress" namespace: "" from "frontend-ing.yaml": no matches for kind "Inrgess" in version "networking.k8s.io/v2"
ensure CRDs are installed firstThe goal is to understand and troubleshoot the errors rather than immediately replacing the manifest with the correct configuration.
Identify the Errors
The manifest has several problems.
Compare the two manifests
Issue 1: Incorrect API Version
The manifest uses an invalid API version, networking.k8s.io/v2. For an Ingress resource, the correct API version is networking.k8s.io/v1. Update the apiVersion field to ensure the Ingress manifest is compatible with the Kubernetes API.
Issue 2: Incorrect Resource Kind
The manifest contains a typo in the resource kind: Inrgess. Kubernetes resource kinds are case-sensitive, so it must be corrected to Ingress for the manifest to be recognized correctly.
Issue 3: Missing Namespace
The application and Service are deployed in the frontend-app namespace, so the Ingress must also be created in the same namespace. Add namespace: frontend-app under the metadata section to ensure the Ingress is associated with the correct namespace.
Issue 4: Missing Ingress Class
The cluster uses the NGINX Ingress controller, so specify ingressClassName: nginx under spec. This tells Kubernetes which Ingress controller should process the Ingress.
Issue 5: Invalid Host
The manifest contains frontend.techiescamp.com/, which has an incorrect trailing /. The host should contain only the hostname, so use frontend.techiescamp.com.
Issue 6: Incorrect Path
The manifest uses path: /*, but the correct path for this configuration is path: /.
Issue 7: Incorrect Path Type
The manifest uses pathType: Inherit, which is not a valid Ingress path type. Use pathType: Prefix instead. The valid path types are Exact, Prefix, and ImplementationSpecific.
Issue 8: Incorrect Service Name
The Ingress references nginx-svc, but the actual application Service is nginx-service. Update the Service name to nginx-service.
Issue 9: Incorrect Service Port
The manifest specifies port 3080, while the application Service exposes port 80. Update the Ingress backend to use port 80.
Apply the Corrected Ingress
Apply the corrected manifest to create the Ingress successfully:
$ kubectl apply -f frontend-ing.yaml
ingress.networking.k8s.io/frontend-ingress createdVerify the Ingress
Check the Ingress in the frontend-app namespace:
$ kubectl get ingress -n frontend-app
NAME CLASS HOSTS ADDRESS PORTS AGE
frontend-ingress nginx frontend.devopscube.com 80 47sYou should see frontend-ingress using the nginx class with the host frontend.devopscube.com and port 80. The ADDRESS value depends on your cluster and Ingress controller configuration.
Verify the Ingress Class
You can also check the available Ingress classes:
$ kubectl get ingressclass
NAME CONTROLLER PARAMETERS AGE
nginx k8s.io/ingress-nginx <none> 5sThe nginx IngressClass should be listed if the NGINX Ingress Controller is installed correctly.
Test the Ingress
The Ingress uses host-based routing for frontend.devopscube.com. If DNS is not configured, you can test the routing by sending the Host header manually with curl. First, identify the NGINX Ingress controller's ClusterIP usingkubectl get svc -A, then send a request to that IP with the appropriate Host header.
kubectl get svc -A
curl -H "Host: frontend.devopscube.com" http://<NGINX-INGRESS-CLUSTER-IP>Replace <NGINX-INGRESS-CLUSTER-IP> with the actual ClusterIP of the NGINX Ingress controller Service.
Expected Response
You should receive the front-end application's homepage, confirming that the Ingress is correctly routing requests to the nginx-service backend.
$ curl -H "Host: frontend.devopscube.com" http://10.103.46.96
<!DOCTYPE html>
<html>
<head>
<title>Application Homepage</title>
</head>
<body>
<h1>You are accessing Application Homepage</h1>
</body>
</html>
root@controlplane:/home/vagrant/test# Why Does the Host Header Matter?
The Ingress rule specifies the host frontend.devopscube.com. The NGINX Ingress controller checks the HTTP Host header to determine which Ingress rule should handle the request.
By using curl with -H "Host: frontend.devopscube.com", you can simulate the required Host header and test host-based routing without configuring DNS.
This is more accurately called Host-header simulation rather than DNS simulation.
CKA Exam Tips
These tips will help you quickly identify the important Kubernetes concepts and avoid common mistakes during the exam.
Tip 1: pathType Is Required
With apiVersion: networking.k8s.io/v1, every Ingress path must specify a valid pathType. Common options are Exact, Prefix, and ImplementationSpecific. For this scenario, use pathType: Prefix.
Tip 2: Don't Put / in the Host
The host must contain only the hostname, without a trailing slash. Use host: frontend.techiescamp.com, not host: frontend.devopscube.com/, because a host is a hostname, not a URL.