K8s "Nginx ingress controller" is creating less number of connection than required

1/26/2020

I am using the "nginx-ingress-controller" to use 'active connections' metrics in my HPA. But Nginx ingress is creating few connections to handle a large number of users. enter image description here enter image description here I am new to Nginx ingress so I don't know if it is expected behavior. I was expecting that 'active connections' should close to the number of concurrent users. Now due to less connection, my application is not scaling.

apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: ggs-hpa
  spec:
   minReplicas: 1
   maxReplicas: 10
   metrics:
   - type: External
     external:
       metricName: custom.googleapis.com|nginx-ingress-controller|nginx_connnections
       targetAverageValue: 6
   scaleTargetRef:
     apiVersion: apps/v1
     kind: Deployment
     name: ggs

I am using JMeter to create these users and my deployment is on the GKE cluster. I am using the default setting of 'nginx-ingress-controller', no customizations in Nginx config.

Can someone please help me to understand this behavior of connections? Thank you.

-- Ajeet
google-kubernetes-engine
kubernetes
kubernetes-ingress
nginx
nginx-ingress

1 Answer

4/10/2020

Sorry I missed to post the solution of the issue. I was not using 'nodeSelector' so nginx pod's node was having multiple pods and these pods were also required high number of connection and a node is having limited number of connections and ports (even after increasing it by tweaking linux settings).

Solution: So I created labels for nodes and using these labels in my nodeSelector to control the deployment of application. Labels I created -

  • ingress
  • monitoring
  • geocoding (my application)
  • testing

Now everything is working fine.

-- Ajeet
Source: StackOverflow