Remove k8s.io/kubernetes dependency
This commit is contained in:
parent
a762d8a4e3
commit
a85e53f4cb
8 changed files with 86 additions and 234 deletions
|
|
@ -18,15 +18,18 @@ package controller
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
api "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/ingress-nginx/internal/ingress"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kubernetes/pkg/util/sysctl"
|
||||
)
|
||||
|
||||
// newUpstream creates an upstream without servers.
|
||||
|
|
@ -52,7 +55,7 @@ func upstreamName(namespace string, service string, port intstr.IntOrString) str
|
|||
// for acceptance (value of net.core.somaxconn)
|
||||
// http://nginx.org/en/docs/http/ngx_http_core_module.html#listen
|
||||
func sysctlSomaxconn() int {
|
||||
maxConns, err := sysctl.New().GetSysctl("net/core/somaxconn")
|
||||
maxConns, err := getSysctl("net/core/somaxconn")
|
||||
if err != nil || maxConns < 512 {
|
||||
klog.V(3).InfoS("Using default net.core.somaxconn", "value", maxConns)
|
||||
return 511
|
||||
|
|
@ -117,3 +120,18 @@ func (nc NginxCommand) ExecCommand(args ...string) *exec.Cmd {
|
|||
func (nc NginxCommand) Test(cfg string) ([]byte, error) {
|
||||
return exec.Command(nc.Binary, "-c", cfg, "-t").CombinedOutput()
|
||||
}
|
||||
|
||||
// getSysctl returns the value for the specified sysctl setting
|
||||
func getSysctl(sysctl string) (int, error) {
|
||||
data, err := ioutil.ReadFile(path.Join("/proc/sys", sysctl))
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
val, err := strconv.Atoi(strings.Trim(string(data), " \n"))
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
return val, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue