请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

nginx-config.yaml不生效

配置应用之后, nginx没有写入响应的配置, 是什么原因呢?

[root@k-master ~]# cat nginx-config.yaml 
kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-configuration
  namespace: ingress-nginx
  labels:
    app: ingress-nginx
data:
  proxy-body-size: "64m"
  proxy-read-timeout: "180"
  proxy-send-timeout: "180"
[root@k-master ~]# kubectl apply -f nginx-config.yaml
configmap/nginx-configuration configured
[root@k-master ~]# kubectl exec -n ingress-nginx -it ingress-nginx-controller-xhjh2 -- cat /etc/nginx/nginx.conf | grep 64
# Configuration checksum: 16664229562195959359
	server_names_hash_bucket_size   64;
	map_hash_bucket_size            64;
	proxy_headers_hash_bucket_size  64;

正在回答

1回答

刘果国 2021-07-01 09:10:06

先用官方给的示例测一下。另外建议直接edit它自动生成的configmap以免名字啥的错误。还可以apply时候同步看ingress-nginx的日志。另外这个是有延迟的,等几十秒再查看

0 回复 有任何疑惑可以回复我~
  • 提问者 qq_慕丝0528892 #1
    我使用相同的指令, 没有看到tcp-service的配置, 所以我没法编辑他自动生成的configmap
    kubectl get cm -n ingress-nginx 
    NAME                              DATA   AGE
    ingress-controller-leader-nginx   0      12d
    ingress-nginx-controller          0      12d
    kube-root-ca.crt                  1      12d
    回复 有任何疑惑可以回复我~ 2021-07-01 20:17:16
  • 提问者 qq_慕丝0528892 #2
    并且我使用apply后, ingress-nginx的日志没有任何变化, 不过之前的日志有错误的级别
    kubectl logs -f -n ingress-nginx ingress-nginx-controller-xhjh2
    
    ...
    E0619 17:41:09.193241       7 leaderelection.go:325] error retrieving resource lock ingress-nginx/ingress-controller-leader-nginx: etcdserver: request timed out
    I0619 17:41:14.336879       7 leaderelection.go:278] failed to renew lease ingress-nginx/ingress-controller-leader-nginx: timed out waiting for the condition
    I0619 17:41:14.428242       7 leaderelection.go:243] attempting to acquire leader lease ingress-nginx/ingress-controller-leader-nginx...
    I0619 17:41:14.870419       7 leaderelection.go:253] successfully acquired lease ingress-nginx/ingress-controller-leader-nginx
    W0619 19:49:07.014081       7 controller.go:981] Service "dev/web-demo" does not have any active Endpoint.
    E0619 21:07:52.725255       7 leaderelection.go:325] error retrieving resource lock ingress-nginx/ingress-controller-leader-nginx: etcdserver: leader changed
    W0619 21:10:29.175191       7 controller.go:981] Service "dev/web-demo" does not have any active Endpoint.
    回复 有任何疑惑可以回复我~ 2021-07-01 20:21:36
  • 提问者 qq_慕丝0528892 #3
    从上面的日志能看出是什么原因吗? 显示有获取资源锁失败, 好像还和etcd有关, 是因为我的ingress-nginx无法连接etcd的原因吗?
    回复 有任何疑惑可以回复我~ 2021-07-01 20:23:34
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信