大网数据广告活动
服务器运维问答

kubernetes dns resolver in nginx

· 52CE 我爱测

I was developing locally in docker-compose , and had an nginx container doing a simple proxy_pass like so: location /app/ { proxy_pass http://webapp:3000/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set…

问题原文

原帖链接 · sharif9876 · CC BY-SA 3.0

I was developing locally in docker-compose, and had an nginx container doing a simple proxy_pass like so:

location /app/ {
    proxy_pass http://webapp:3000/;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;

    resolver 127.0.0.11;
}

I now want to move over to kubernetes in GKE, and the last line is giving me troubles.

I tried to switch the resolver to:

    resolver kube-dns;

I also tried various other IPs and names, but I keep getting an error along the lines of:

nginx: [emerg] host not found in resolver "kube-dns"

My kubernetes setup is that I have a single pod, with 2 containers: 'webapp' and 'nginx'. I simply want to have an external service pointing to nginx that can proxy_pass to webapp.

Any ideas?

社区高分解答

原帖链接 · Robert Keck · CC BY-SA 4.0

You have to specify the FQDN for the kube-dns and the services.
For GKE kube-dns standard for example, it would be: kube-dns.kube-system.svc.cluster.local
And if you're on the default namespace with your webapp service, it would be: webapp.default.svc.cluster.local

I know the original question is old, but maybe it helps someone.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-09-30)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。