last day (15 days later) » 

3:48 PM
0
Q: Adding host without www not working with Ingress resource

opensource-developerI have a couple of questions When we make changes to ingress resource, are there any cases where we have to delete the resource and re-create it again or is kubectl apply -f <file_name> sufficient? When I add the host attribute without www i.e. (my-domain.in), I am not able to access my applic...

 
You don't have to delete Ingress objects to update it, the kubectl apply is the recommended format. Either it will show ingress.networking.k8s.io/ingress unchanged or ingress.networking.k8s.io/ingress configured. this Ingress you posted, is the working one? Please explain the desired state so we can troubleshoot the syntax and rule.
 
hi @willrof, the issue is that in the host if i don't specify www, like you see in the file above, my application does not load. But when i add www to the host it works. I will update my question, sorry for not being clear
@willrof, just updated the question with more details. Thanks.
 
Thank you for enhancing the question. I believe it's a DNS question. There is a way you can test that, from kubernetes outwards. I'll post all my troubleshooting suggestion as an answer since a domain problem is ayways a case-by-case scenario.
 
thanks @willrof, look forward to it
 
one last question, how many services do you have exposed in your kubernetes? because if ALL you need is to define a default route for the requests there are easier ways to do this. I believe you have a lot of services and that you redacted them from the ingress and your problem is only with the default backend?
 
3:48 PM
just have one NodePort type service
 
Do you mind posting the output of kubectl get svc? If I'm correct you really don't need to worry about domain rules, just a default rule without hostname would suffice.
 
eks-learning-service NodePort 1.10.13.12 <none> 80:32436/TCP 22h redis ClusterIP 1.10.7.4 <none> 6379/TCP 42m
hi
 
Hey there
It's easier this way.
 
i tried removing the host but now i am not able to access my application
yes, many thanks for taking time :)
here is the url
 
Do you know th econcept of LoadBalancer Service Type?
because I see you are using NodePort
if you expose your service as LoadBalancer you don't even have to worry about Ingress
 
3:49 PM
yep, but i have read that its costly and spins up a new lb everytime
if we add services
actually, i am also porting a app from GCE to AWS and we are using ingress in GCE
 
and you intent on creating more services and domains...I get it.
 
yeah, GCE is great, why are you going to AWS?
 
i am having trouble indetifying the root cause as to why without www i am not able to access the application
and all this works if i had a host: www.eks-aws-learning.in to my ingress resource
 
now that we are dealing with real links
 
3:52 PM
actully, we have other apps on AWS, hence want to have eveyrthing under one place
 
I can definitely say it's a DNS issue.
 
❯ nslookup www.eks-aws-learning.in
Server: 127.0.0.1
Address: 127.0.0.1#53

Non-authoritative answer:
www.eks-aws-learning.in canonical name = b24c9c58-production-ekslea-b134-1014542132.us-east-1.elb.amazonaws.com.
Name: b24c9c58-production-ekslea-b134-1014542132.us-east-1.elb.amazonaws.com
Address: 3.214.99.59
Name: b24c9c58-production-ekslea-b134-1014542132.us-east-1.elb.amazonaws.com
Address: 52.23.131.173


~
❯ nslookup eks-aws-learning.in
Server: 127.0.0.1
Address: 127.0.0.1#53
 
we are on part 1 again. Domain DNS
 
3:53 PM
i see. ok
 
shorter answer to your question: You can't access without WWW because there is no DNS rule for the domain without www.
 
but how would adding host: www.eks-aws-learning.in fix the DNS issue?
 
because www.eks-aws-learning.in is registered in your Godaddy
and is forwarding the requests to AWS IP
one second
 
no sorry, i meant adding host to ingress
so, when i update my ingress resource, with host: www.eks-aws-learning.in, i am able to access application with or without www
also, additinally, i have setup a rule in my ALB to foward non www, i.e. eks-aws-learning.in to https
sure
 
the point is:
the request WITHOUT www is not going anywhere
 
3:57 PM
yes, that makes sense because without www is not registered anywhere
but, whats not clear is when i add host: www.eks-aws-learning.in to my ingress resource
without www also works, which is good,but i dont understand why :(
 
one second...I'm still confuse why it's not getting it to Godaddy
 
because godaddy does not support blank host when adding cname records
I cant add a A type record to godaddy because i dont have a static public IP of my ALB, i can only see the DNS name under my Load balancer settings
 
cool, i am checking now, thanks
 
you need to do the entire domain redirect, this way the root of the domain will be redirected to AWS..and you configure your subdomains (when needed) on your AWS DNS.
 
4:06 PM
ok cool, trying it now, many mnay thanks
 
no problem.
once you forward your entire domain, may take up to 24 hous to propagate
but after that, I believe your ingress will work for any subdomain.
 
so, i need to forward my domain to ALB DNS name correct?
 
Correct
 
ok awesome, this should fix it
 
Thank you for your Upvote, If you could mark it as accepted as well would mean a lot to me.
 
4:08 PM
any idea why adding host to the ingress works
yes, i will for sure mark as accepted
 
@opensource-developer what do you mean?
 
so when i add to my ingress resource under http, host: www.eks-aws-learning.in, i am able to access the app with or without www.
ah no, i think it was cached
:(
 
yes, probably was that
 
wow, thanks for helping, adding host to ingress wont work till i foward my domain i think
 
when doing this kind of test, it's better to test with curl instead of browser
 
4:11 PM
but once forwarded, do i need to do any extra setting for non www to work?
yes, curl is a great idea, many thanks
 
yes, you need to forward it...Godaddy will say up to 48 hours...but the truth is that after a few hours the forward usually gets to work.
sometimes is even 15 minutes.
 
cool, so after i forward
both www and non www will work?
 
of tomorrow you still have problems, let me know
yes, since all traffic will be redirected to the ALB
it will be up to ALB to decide what to do with any traffice sent to your domain.
 
awesome, i have accepted your answer and wait till forwarding is complete
 
since the www is already working, I believe both www and non www will work the same way.
 
4:13 PM
cool
 
glad to help.
 
sorry one more quesrions, is there a good book where i can understand some basic networking concepts?
 
let me se...
Actually there is a ton of books, but there is a lot of courses available on the internet
udemy, coursera, etc
and some free courses too
 
4:36 PM
awesome, thanks :)
 

last day (15 days later) »