I am using LAB,ingress setup not working..able to acces the service in the browser..given all soources

apiVersion: apps/v1
kind: Deployment
metadata:
name: webapp-deployment
labels:
app: webapp
spec:
replicas: 2 # Number of pods
selector:
matchLabels:
app: webapp
template:
metadata:
labels:
app: webapp
spec:
containers:
- name: webapp-container
image: nginx:alpine # Simple web server using NGINX
ports:
- containerPort: 80
apiVersion: v1
kind: Service
metadata:
name: webapp-service
spec:
selector:
app: webapp # Connects to pods with label ‘app: webapp’
ports:
- protocol: TCP
port: 80 # Exposes on this port
targetPort: 80 # Port inside the pod
type: NodePort # LoadBalancer type service

apiVersion: apps/v1
kind: Deployment
metadata:
name: webapp-deployment
labels:
app: webapp
spec:
replicas: 2 # Number of pods
selector:
matchLabels:
app: webapp
template:
metadata:
labels:
app: webapp
spec:
containers:
- name: webapp-container
image: nginx:alpine # Simple web server using NGINX
ports:
- containerPort: 80
apiVersion: v1
kind: Service
metadata:
name: webapp-service
spec:
selector:
app: webapp # Connects to pods with label ‘app: webapp’
ports:
- protocol: TCP
port: 80 # Exposes on this port
targetPort: 80 # Port inside the pod
type: NodePort # LoadBalancer type service

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: webapp-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:

curl http://webapp.local
curl: (6) Could not resolve host: webapp.local

also /etc/host file with 192.168.75.137 webapp.local,192.168.75.13(ingress address)
~

k describe ingress webapp-ingress
Name: webapp-ingress
Labels:
Namespace: default
Address: 192.168.75.137
Ingress Class: traefik
Default backend:
Rules:
Host Path Backends


webapp.local
/ webapp-service:80 (10.42.0.9:80,10.42.0.10:80)
Annotations: nginx.ingress.kubernetes.io/rewrite-target: /
Events:

We cannot make sense of the YAML you have posted in your first message. Indentation is significant and all that has been lost

Please paste as code block so it looks like this

apiVersion: apps/v1
kind: Deployment
metadata:
  name: webapp-deployment
  labels:
    app: webapp

And also which ingress lab (there are 2). Please paste a link to it



just to inform you indentation is correct only…here in this copy…it;s not taking identaion properly…i tried to zip all files…but it’s not taking zip also…added screenshot…i am using lab(practice test-pods lab) from k adminstatror course-i have installed nginx ingress controller manually…kindly help on the issue mentioned…i noticed one more thing…sometime i get address(ip) for ingress and sometime don’t!!

https://learn.kodekloud.com/user/courses/cka-certification-course-certified-kubernetes-administrator/module/c6d2ac7d-8192-4cff-aa54-e36d888c5bd9/lesson/883e9799-b423-4926-ad8f-b0e5589eaf79


ingress address(IP) is not getting assigned…

So, you’re using the lab " Practice Test - Pods" for testing an ingress, based on that lab link. There is an ingress controller installed, although it’s not the ingress-nginx IC – it’s the traefik IC, which will not understand the annotations you’re using, and likely would not respond to that ingressClassName either.

I’d check your ingress definition, but while we can understand your YAML, we can’t really do anything with it. What you’d need to do is:

  1. Use the </> button to create a code box for the YAML.
  2. Paste into the resulting box, which looks like this:
    Screenshot 2025-01-12 at 8.46.39 PM

Alternatively, you can use one of the ingress labs from later in the course (this one is a good choice) which has the ingress-nginx ingress controller pre-installed.

Let me check the lab u suggested and update-after some time.it was not loading the morning…but morning i used K8 playground with multi node cluster…there also got a similar error mentioned…can you help me?


Hi @rob_kodekloud ,it’s working now …thanks a ton…is there way to access the same webapp.local in my browser?

Given how the web works, and the way that our labs are wired up, I don’t think so. The ingress controller is accessed using a service that exposes the main controller pod; this is a NodePort service as we set up the controller. If you want to use the “host” field, the IP of that host needs to resolve to IP of a node of the lab’s cluster, or it won’t work. What you can do as well is use the menu and expose the nodeport that the IC is using. This will let you view in your browser. You’ll need to remove the “host” item though, since the browser page will not use the right hosts header for this work with your ingress resource.

thanks for the clarity @rob_kodekloud