Skip to content

Commit ccd5c81

Browse files
committed
MINOR: add setting for channels size
Setting the channel size has direct effect in performance in crowded cluster. Too many resources implies a delay in readiness, a general slowdown and even a skip of event if the channel gets full.
1 parent 660488b commit ccd5c81

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

controller/controller.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,16 @@ func (c *HAProxyController) Start() {
117117
}
118118

119119
// Monitor k8s events
120-
c.eventChan = make(chan SyncDataEvent, watch.DefaultChanSize*6)
120+
var chanSize int64 = int64(watch.DefaultChanSize * 6)
121+
if c.OSArgs.ChannelSize > 0 {
122+
chanSize = c.OSArgs.ChannelSize
123+
}
124+
logger.Infof("Channel size: %d", chanSize)
125+
c.eventChan = make(chan SyncDataEvent, chanSize)
121126
go c.monitorChanges()
122127
if c.PublishService != nil {
123128
// Update Ingress status
124-
c.ingressChan = make(chan ingress.Sync, watch.DefaultChanSize*6)
129+
c.ingressChan = make(chan ingress.Sync, chanSize)
125130
go ingress.UpdateStatus(c.k8s.API, c.Store, c.OSArgs.IngressClass, c.OSArgs.EmptyIngressClass, c.ingressChan)
126131
}
127132
}

controller/utils/flags.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,5 @@ type OSArgs struct { //nolint:maligned
100100
DisableServiceExternalName bool `long:"disable-service-external-name" description:"disable forwarding to ExternalName Services due to CVE-2021-25740"`
101101
UseWiths6Overlay bool `long:"with-s6-overlay" description:"use s6 overlay to start/stpop/reload HAProxy"`
102102
PromotheusPort int64 `long:"enable-prometheus-port" description:"port to listen on for Prometheus metrics"`
103+
ChannelSize int64 `long:"channel-size" description:"sets the size of controller buffers used to receive and send k8s events.NOTE: increase the value to accommodate large number of resources "`
103104
}

documentation/controller.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Image can be run with arguments:
3636
| [`--config-dir`](#--config-dir) | `/tmp/haproxy-ingress/etc` |
3737
| [`--runtime-dir`](#--runtime-dir) | `/tmp/haproxy-ingress/run` |
3838
| [`--disable-service-external-name`](#--disable-service-external-name) | `false` |
39+
| [`--channel-size`](#--channel-size) | `600` |
3940

4041

4142
### `--configmap`
@@ -654,3 +655,24 @@ args:
654655

655656
***
656657

658+
### `--channel-size`
659+
660+
Sets the size of controller buffers used to receive and send k8s events.
661+
This parameter is a cursor to adapt to the number of resources inside your clusters and that generate a lot of events.
662+
Rule of thumb: the more resources the higher the value.
663+
664+
Possible values:
665+
666+
- Size of channels used for k8s resources events with regards to ingresses, etc.
667+
668+
Example:
669+
670+
```yaml
671+
args:
672+
- --channel-size=10000
673+
```
674+
675+
<p align='right'><a href='#haproxy-kubernetes-ingress-controller'>:arrow_up_small: back to top</a></p>
676+
677+
***
678+

documentation/doc.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,18 @@ image_arguments:
382382
helm: |-
383383
helm install haproxy haproxytech/kubernetes-ingress \
384384
--set-string "controller.extraArgs={--disable-service-external-name}"
385+
- argument: --channel-size
386+
description: |-
387+
Sets the size of controller buffers used to receive and send k8s events.
388+
This parameter is a cursor to adapt to the number of resources inside your clusters and that generate a lot of events.
389+
Rule of thumb: the more resources the higher the value.
390+
values:
391+
- Size of channels used for k8s resources events with regards to ingresses, etc.
392+
default: 600
393+
version_min: "1.7"
394+
example: |-
395+
args:
396+
- --channel-size=10000
385397
groups:
386398
config-snippet:
387399
header: |-

0 commit comments

Comments
 (0)