优化nginx-ingress-controller性能

1.首先优化ingress-controller

通过 Helm 安装 Nginx Ingress 的默认关联配置映射实例名称为 nginx-ingress-controller,用户可以通过修改资源对象 Deployment/DaemonSet 实例 nginx-ingress-controller 中的参数 --configmap 自定义关联配置映射实例的名称。

于是参考nginx-ingress-controller的ConfigMap配置方法,这里配置了下:

$ kubectl -n kube-system edit configmap nginx-configuration
...
apiVersion: v1
kind: ConfigMap
data:
  allow-backend-server-header: 'true'
  enable-underscores-in-headers: 'true'
  generate-request-id: 'true'
  ignore-invalid-headers: 'true'
  keep-alive: '75'
  keep-alive-requests: '1000'
  max-worker-connections: '65536'
  proxy-body-size: 80m
  proxy-connect-timeout: '10'
  reuse-port: 'true'
  server-tokens: 'false'
  ssl-redirect: 'false'
  upstream-keepalive-connections: '1000'
  upstream-keepalive-requests: '10000'
  upstream-keepalive-timeout: '60'
  worker-cpu-affinity: auto

 

2.参考ingress的Annotations配置方法,优化具体deployment.yml里的ingress 配置

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "20"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "20"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "20"
    nginx.ingress.kubernetes.io/connection-proxy-header: "keep-alive"
    nginx.ingress.kubernetes.io/proxy-http-version: "1.1"
    nginx.ingress.kubernetes.io/proxy-body-size: 80m

 

参考:

https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/

http://www.weixueyuan.net/a/877.html

https://www.iyunw.cn/archives/ingress-nginx-keng-dian-chi-xu-geng-xin/

https://cloud.tencent.com/developer/article/1537695

上一篇:K8S 之 为K8S集群搭建七层代理服务Ingress(高可用)


下一篇:如何在Rancher 2.x中升级cert-manager?