问题原文
原帖链接 · 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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
