Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change configuration parameters of ingress controller in kubernetes

I have setup a web application in kubernetes with a nginx-ingress controller. I am able to access my application over the Nginx ingress controller public IP.

For requests which are taking more than 1 min, we are getting gateway connection timeout error (504). I've checked the Nginx ingress controller configuration by connecting to the pod and it has connection_timeout value is 60s. (root cause of the issue)

I have tried changing the parameters to higher values and its work fine for long requests, though Nginx ingress controller configuration got reloaded to default after some time.

How can we change/persist the Nginx ingress controller configuration parameters?

Appreciate any help. Thanks in advance.

like image 386
Rahul Khengare Avatar asked Aug 30 '17 12:08

Rahul Khengare


2 Answers

The nginx ingress controller is customizable via a configmap.

You can achieve this by passing the argument --configmap to the ingress controller. Source: https://github.com/kubernetes/ingress/tree/master/controllers/nginx#command-line-arguments

In the kube-system namespace, create a configmap, give it name like nginx-load-balancer-conf and then edit your ingress controller's replication controller or daemonset and add the --configmap=nginx-load-balancer-conf argument.

Here's an example of what that configmap could look like:

apiVersion: v1
data:
  proxy-connect-timeout: "10"
  proxy-read-timeout: "120"
  proxy-send-timeout: "120"
kind: ConfigMap
metadata:
  name: nginx-load-balancer-conf

And here's how you create it, if you were to save the above to a file called nginx-load-balancer-conf.yaml

kubectl create -f nginx-load-balancer-conf.yaml

EDIT

The documentation has moved, the valid links to these documents are now here:

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

like image 101
Oliver Nicolaas Ponder Avatar answered Sep 27 '22 00:09

Oliver Nicolaas Ponder


I am running Minikube v0.28.0 on a Mac and was able to modify the config map for nginx controller (started using add-on) using the following command:

bash-3.2$ kubectl edit pod/nginx-ingress-controller-67956bf89d-m2wd9 -n kube-system

Edit the file by adding/removing properties and then save/quit. If you tail the log for the nginx-controller pod, you will see the config map getting updated dynamically (no need to restart the pod):

I0720 20:22:16.835539       7 event.go:218] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"kube-system", Name:"nginx-load-balancer-conf", UID:"f7dfcf62-8b6b-11e8-933d-08002782c59f", APIVersion:"v1", ResourceVersion:"69386", FieldPath:""}): type: 'Normal' reason: 'UPDATE' ConfigMap kube-system/nginx-load-balancer-conf
like image 28
Vinod Avatar answered Sep 27 '22 00:09

Vinod