values.yaml configuration method:controller:extraInitContainers:- name: sysctlimage: busyboximagePullPolicy: IfNotPresentsecurityContext:privileged: truecommand:- sh- -c- |sysctl -w net.core.somaxconn=65535 # Increase connection queue to prevent queue overflow.sysctl -w net.ipv4.ip_local_port_range="1024 65535" # Expand the source port range to prevent port exhaustion.sysctl -w net.ipv4.tcp_tw_reuse=1 # Enable TIME_WAIT reuse to allow new connections after port exhaustion.sysctl -w fs.file-max=1048576 # Increase the file handle count to prevent connection overflow from exhausting file handles.config:# The number of requests that can be processed by a persistent connection between Nginx and the client is 100 by default. We recommend increasing this number in high-concurrency scenarios, but setting it too high may cause uneven load after Nginx Ingress scale-out.# Reference: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#keep-alive-requestskeep-alive-requests: "1000"# The maximum number of idle persistent connections (not the maximum number of connections) between Nginx and the upstream is 320 by default. We recommend increasing this number in high-concurrency scenarios to prevent the frequent establishment of connections from significantly increasing the number of TIME_WAIT connections.# Reference: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#upstream-keepalive-connectionsupstream-keepalive-connections: "2000"# The maximum number of connections that each worker process can open is 16384 by default.# Reference: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#max-worker-connectionsmax-worker-connections: "65536"
values.yaml configuration method:controller:config:# Nginx logs are written to log files to avoid high CPU utilization under high concurrency.access-log-path: /var/log/nginx/nginx_access.logerror-log-path: /var/log/nginx/nginx_error.logextraVolumes:- name: log # Log mounting directory of the controlleremptyDir: {}extraVolumeMounts:- name: log # Log directory shared by the logrotate and controllermountPath: /var/log/nginxextraContainers: # Logrotate sidecar container for log rotation- name: logrotateimage: imroc/logrotate:latest # https://github.com/imroc/docker-logrotateimagePullPolicy: IfNotPresentenv:- name: LOGROTATE_FILE_PATTERN # Pattern of rotated log files, matching the log file path configured in Nginxvalue: "/var/log/nginx/nginx_*.log"- name: LOGROTATE_FILESIZE # Threshold of log file size for rotationvalue: "100M"- name: LOGROTATE_FILENUM # Number of rotations per log filevalue: "3"- name: CRON_EXPR # Crontab expression for periodic logrotate running, which is once every minutevalue: "*/1 * * * *"- name: CROND_LOGLEVEL # Crond log level, ranging from 0 to 8, the smaller the value, the more detailedvalue: "8"volumeMounts:- name: logmountPath: /var/log/nginx
Feedback