如何将Nginx Pod设置为kubernetes负载均衡器?

时间:2020-10-02 23:32:51

标签: nginx kubernetes kubernetes-ingress round-robin

我正在尝试设置一个Nginx Pod,以使用DNS而不是IP地址来执行轮询。我目前正在关注此文档:

https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/

到目前为止,我已经尝试过了,这是.yaml kubernetes清单的一部分:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC

但是我看到这个错误:

....
data:
 nginx.conf: |
   http {
     upstream backend {
     server1.com;
     server2.com;
     server3.com;
     } 
     server { 
     location / {
     proxy_pass http://backend;
        }
      }
    }
kind: ConfigMap
....

由于Kubernetes不断重新启动容器,所以我无法将其装入其中。但是在类似条件下使用已知良好的Nginx容器,我可以说configmap插入/etc/nginx/conf.d/nginx.conf

/etc/nginx/conf.d/default.conf中也没有。最后,/ etc / nginx / nginx.conf仍然存在。我读到/etc/nginx/nginx.conf中的http部分可以影响我想做的事情,但是我不清楚如何正确解决此问题

有人可以帮我指出正确的方向吗?

当我删除http {}部分时,会出现另一种错误:

[emerg] 1#1: "http" directive is not allowed here in /etc/nginx/conf.d/nginx.conf:1

0 个答案:

没有答案
相关问题