I just had the CKAD exam today, and I got a question that I don’t know how to do. The question requires creating an ingress resource to expose the application to an URL (e.g. external.A.local, I cannot remember all the URL). The service has already created and expose at 8080.
I created the ingress as below:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-name
namespace: external
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx-example
rules:
- host: external.A.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: webapp
port:
number: 8080
After that, I tried to access the page using “curl http://external.A.local/,” but it said the page was not found. Has anyone faced a similar question?
That ingress resource as printed above is invalid – no indentation. Not sure how you edited that, because unless it was correctly indented, kubectl would have rejected it.
Let’s assume that you did have a version of the above that was correctly indented and it applied. It’s also not clear if the ingress controller in question is available at port 80. If port 80 is supported, then the curl command should work.
Sorry, the yaml I copied from another place, when I pasted in here, the indentation dissapeared. The indentation is correct. I do not know if the ingress available at port 80 or not. The question just indicates that the app needed to be exposed at external.A.local, so it asks me to create the ingress resource to do that.
At the end, it tells that I can check using the curl command.
Is there any way to check if the ingress is available at port 80 or not?
You’d need to look at how the ingress controller was installed. Typically the actual controller is a deployment, and there’s a service defined that exposes a LoadBalancer that makes 443 and 80 available.
Thank you so much, I will have a look back at this part more carefully