Skip to content

Commit

Permalink
Merge pull request #1352 from ChenLingPeng/kube-scale
Browse files Browse the repository at this point in the history
Allow more events to be buffered before the backend starts
  • Loading branch information
luthermonson authored Apr 14, 2022
2 parents 3357ec2 + 489e566 commit 349feae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Documentation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ The command line options outlined above can also be specified via environment va
For example `--etcd-endpoints=http://10.0.0.2:2379` is equivalent to `FLANNELD_ETCD_ENDPOINTS=http://10.0.0.2:2379` environment variable.
Any command line option can be turned into an environment variable by prefixing it with `FLANNELD_`, stripping leading dashes, converting to uppercase and replacing all other dashes to underscores.
`EVENT_QUEUE_DEPTH` is another environment variable to indicate the kubernetes scale. Set `EVENT_QUEUE_DEPTH` to adapter your cluster node numbers. If not set, default value is 5000.
## Health Check
Flannel provides a health check http endpoint `healthz`. Currently this endpoint will blindly
Expand Down
2 changes: 2 additions & 0 deletions Documentation/kube-flannel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: EVENT_QUEUE_DEPTH
value: "5000"
volumeMounts:
- name: run
mountPath: /run/flannel
Expand Down
14 changes: 13 additions & 1 deletion subnet/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"io/ioutil"
"net"
"os"
"strconv"
"time"

"github.com/flannel-io/flannel/pkg/ip"
Expand Down Expand Up @@ -141,7 +142,18 @@ func newKubeSubnetManager(ctx context.Context, c clientset.Interface, sc *subnet
ksm.client = c
ksm.nodeName = nodeName
ksm.subnetConf = sc
ksm.events = make(chan subnet.Event, 5000)
scale := 5000
scaleStr := os.Getenv("EVENT_QUEUE_DEPTH")
if scaleStr != "" {
n, err := strconv.Atoi(scaleStr)
if err != nil {
return nil, fmt.Errorf("env EVENT_QUEUE_DEPTH=%s format error: %v", scaleStr, err)
}
if n > 0 {
scale = n
}
}
ksm.events = make(chan subnet.Event, scale)
indexer, controller := cache.NewIndexerInformer(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
Expand Down

0 comments on commit 349feae

Please sign in to comment.