From f86b0cdbba7ab3ab4cd3ae85c9238d0899c9ea10 Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Mon, 6 Apr 2020 12:34:19 -0400 Subject: [PATCH] Add lifecycle hook and option to enable mimalloc --- .../templates/controller-daemonset.yaml | 4 ++++ .../templates/controller-deployment.yaml | 4 ++++ charts/ingress-nginx/values.yaml | 22 ++++++++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/charts/ingress-nginx/templates/controller-daemonset.yaml b/charts/ingress-nginx/templates/controller-daemonset.yaml index b3a90d866..e9498c530 100644 --- a/charts/ingress-nginx/templates/controller-daemonset.yaml +++ b/charts/ingress-nginx/templates/controller-daemonset.yaml @@ -110,6 +110,10 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + {{- if .Values.controller.enableMimalloc }} + - name: LD_PRELOAD + value: /usr/local/lib/libmimalloc.so + {{- end }} {{- if .Values.controller.extraEnvs }} {{- toYaml .Values.controller.extraEnvs | nindent 12 }} {{- end }} diff --git a/charts/ingress-nginx/templates/controller-deployment.yaml b/charts/ingress-nginx/templates/controller-deployment.yaml index e3d1b093d..fd10da73e 100644 --- a/charts/ingress-nginx/templates/controller-deployment.yaml +++ b/charts/ingress-nginx/templates/controller-deployment.yaml @@ -113,6 +113,10 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + {{- if .Values.controller.enableMimalloc }} + - name: LD_PRELOAD + value: /usr/local/lib/libmimalloc.so + {{- end }} {{- if .Values.controller.extraEnvs }} {{- toYaml .Values.controller.extraEnvs | nindent 12 }} {{- end }} diff --git a/charts/ingress-nginx/values.yaml b/charts/ingress-nginx/values.yaml index 2b499f53f..a41b0ea93 100644 --- a/charts/ingress-nginx/values.yaml +++ b/charts/ingress-nginx/values.yaml @@ -188,8 +188,9 @@ controller: # topologyKey: "kubernetes.io/hostname" ## terminationGracePeriodSeconds + ## wait up to five minutes for the drain of connections ## - terminationGracePeriodSeconds: 60 + terminationGracePeriodSeconds: 300 ## Node labels for controller pod assignment ## Ref: https://kubernetes.io/docs/user-guide/node-selection/ @@ -245,6 +246,11 @@ controller: targetCPUUtilizationPercentage: 50 targetMemoryUtilizationPercentage: 50 + ## Enable mimalloc as a drop-in replacement for malloc. + ## ref: https://github.com/microsoft/mimalloc + ## + enableMimalloc: false + ## Override NGINX template customTemplate: configMapName: "" @@ -427,8 +433,18 @@ controller: # description: Too many 4XXs # summary: More than 5% of the all requests did return 4XX, this require your attention - - lifecycle: {} + ## Improve connection draining when ingress controller pod is deleted using a lifecycle hook: + ## With this new hook, we increased the default terminationGracePeriodSeconds from 30 seconds + ## to 300, allowing the draining of connections up to five minutes. + ## If the active connections end before that, the pod will terminate gracefully at that time. + ## To efectively take advantage of this feature, the Configmap feature + ## worker-shutdown-timeout new value is 240s instead of 10s. + ## + lifecycle: + preStop: + exec: + command: + - /wait-shutdown priorityClassName: ""