diff --git a/pkg/proxy/userspace/proxier.go b/pkg/proxy/userspace/proxier.go index a9f49fedf0c..930f9634ede 100644 --- a/pkg/proxy/userspace/proxier.go +++ b/pkg/proxy/userspace/proxier.go @@ -23,6 +23,7 @@ import ( "strings" "sync" "sync/atomic" + "syscall" "time" "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) } + err = setRLimit(64 * 1000) + if err != nil { + return nil, fmt.Errorf("failed to set open file handler limit", err) + } + proxyPorts := newPortAllocator(pr) glog.V(2).Infof("Setting proxy IP to %v and initializing iptables", hostIP) 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) { // convenient to pass nil for tests.. if proxyPorts == nil {