DNS does not resolve with NGINX in Kubernetes

0 votes

I have a kubernetes cluster with AWS. 

I'm trying to run a custom NGINX configuration which uses DNS resolutions to proxy_pass. 

location /api/v1/lead {
  resolver 10.3.0.10 ipv6=off;
  set $container lead-api;
  proxy_pass http://$container:3000;
}

I get the following error in the NGINX logs of the Kubernetes cluster

[error] 9#9: *20 lead-api could not be resolved (2: Server failure), client: 10.2.26.0, server: , request: "GET /api/v1/lead/661DF757-722B-41BB-81BD-C7FD398BBC88 HTTP/1.1"
Aug 30, 2018 in Kubernetes by Hannah
• 14,070 points
475 views

2 answers to this question.

0 votes
use the Full Qualified Domain name. That is, you should use:

lead-api.<namespace>.svc.cluster.local

not just

lead-api
answered Aug 30, 2018 by Kalgi
• 40,420 points
0 votes

adding to @kalgi's answer

Using just the hostname will usually work because in kubernetes the resolv.conf is configured with search domains so that you don't usually need to provide a service's FQDN. e.g:

search default.svc.cluster.local svc.cluster.local cluster.local
nameserver 10.3.240.10
options ndots:5
answered Aug 30, 2018 by Nilesh
• 6,880 points

Related Questions In Kubernetes

0 votes
1 answer

How does DNS work in kubernetes?

DNS is a built-in service in Kubernetes. ...READ MORE

answered Jul 12 in Kubernetes by Sirajul
• 25,180 points
31 views
0 votes
1 answer

Not able to access kubernetes api from a pod in azure

Follow these steps Add --bind-address=0.0.0.0 option to the line https://github.com/kubernetes/kubernetes/blob/v1.2.0/docs/getting-started-guides/coreos/azure/cloud_config_templates/kubernetes-cluster-main-nodes-template.yml#L218  Created ...READ MORE

answered Aug 30, 2018 in Kubernetes by Kalgi
• 40,420 points
56 views
0 votes
1 answer
0 votes
1 answer

Ingress nginx loading resource 404 in kubernetes

This is not a routing problem on ...READ MORE

answered Sep 10, 2018 in Kubernetes by Kalgi
• 40,420 points
854 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
145 views
0 votes
1 answer
0 votes
1 answer

Error saying "The specified bucket does not exist" in kubernetes

Bucket is created in another region. Looks like ...READ MORE

answered Aug 31, 2018 in Kubernetes by Kalgi
• 40,420 points
279 views
0 votes
1 answer