mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Set rlimit for openfile handles to 64k
This commit is contained in:
parent
8e4b09df8f
commit
6945cb050c
@ -23,6 +23,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
@ -146,12 +147,21 @@ func NewProxier(loadBalancer LoadBalancer, listenIP net.IP, iptables iptables.In
|
|||||||
return nil, fmt.Errorf("failed to select a host interface: %v", err)
|
return nil, fmt.Errorf("failed to select a host interface: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = setRLimit(64 * 1000)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to set open file handler limit", err)
|
||||||
|
}
|
||||||
|
|
||||||
proxyPorts := newPortAllocator(pr)
|
proxyPorts := newPortAllocator(pr)
|
||||||
|
|
||||||
glog.V(2).Infof("Setting proxy IP to %v and initializing iptables", hostIP)
|
glog.V(2).Infof("Setting proxy IP to %v and initializing iptables", hostIP)
|
||||||
return createProxier(loadBalancer, listenIP, iptables, hostIP, proxyPorts, syncPeriod)
|
return createProxier(loadBalancer, listenIP, iptables, hostIP, proxyPorts, syncPeriod)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setRLimit(limit uint64) error {
|
||||||
|
return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &syscall.Rlimit{Max: limit, Cur: limit})
|
||||||
|
}
|
||||||
|
|
||||||
func createProxier(loadBalancer LoadBalancer, listenIP net.IP, iptables iptables.Interface, hostIP net.IP, proxyPorts PortAllocator, syncPeriod time.Duration) (*Proxier, error) {
|
func createProxier(loadBalancer LoadBalancer, listenIP net.IP, iptables iptables.Interface, hostIP net.IP, proxyPorts PortAllocator, syncPeriod time.Duration) (*Proxier, error) {
|
||||||
// convenient to pass nil for tests..
|
// convenient to pass nil for tests..
|
||||||
if proxyPorts == nil {
|
if proxyPorts == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user