mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 05:46:16 +00:00
flag controlled RLIMIT_NOFILE for kubelet.
This commit is contained in:
parent
843134885e
commit
38583307ca
@ -105,6 +105,7 @@ type KubeletServer struct {
|
|||||||
ManifestURLHeader string
|
ManifestURLHeader string
|
||||||
MasterServiceNamespace string
|
MasterServiceNamespace string
|
||||||
MaxContainerCount int
|
MaxContainerCount int
|
||||||
|
MaxOpenFiles uint64
|
||||||
MaxPerPodContainerCount int
|
MaxPerPodContainerCount int
|
||||||
MaxPods int
|
MaxPods int
|
||||||
MinimumGCAge time.Duration
|
MinimumGCAge time.Duration
|
||||||
@ -183,6 +184,7 @@ func NewKubeletServer() *KubeletServer {
|
|||||||
MasterServiceNamespace: api.NamespaceDefault,
|
MasterServiceNamespace: api.NamespaceDefault,
|
||||||
MaxContainerCount: 100,
|
MaxContainerCount: 100,
|
||||||
MaxPerPodContainerCount: 2,
|
MaxPerPodContainerCount: 2,
|
||||||
|
MaxOpenFiles: 1000000,
|
||||||
MinimumGCAge: 1 * time.Minute,
|
MinimumGCAge: 1 * time.Minute,
|
||||||
NetworkPluginDir: "/usr/libexec/kubernetes/kubelet-plugins/net/exec/",
|
NetworkPluginDir: "/usr/libexec/kubernetes/kubelet-plugins/net/exec/",
|
||||||
NetworkPluginName: "",
|
NetworkPluginName: "",
|
||||||
@ -275,6 +277,7 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
|
|||||||
fs.BoolVar(&s.ReallyCrashForTesting, "really-crash-for-testing", s.ReallyCrashForTesting, "If true, when panics occur crash. Intended for testing.")
|
fs.BoolVar(&s.ReallyCrashForTesting, "really-crash-for-testing", s.ReallyCrashForTesting, "If true, when panics occur crash. Intended for testing.")
|
||||||
fs.Float64Var(&s.ChaosChance, "chaos-chance", s.ChaosChance, "If > 0.0, introduce random client errors and latency. Intended for testing. [default=0.0]")
|
fs.Float64Var(&s.ChaosChance, "chaos-chance", s.ChaosChance, "If > 0.0, introduce random client errors and latency. Intended for testing. [default=0.0]")
|
||||||
fs.BoolVar(&s.Containerized, "containerized", s.Containerized, "Experimental support for running kubelet in a container. Intended for testing. [default=false]")
|
fs.BoolVar(&s.Containerized, "containerized", s.Containerized, "Experimental support for running kubelet in a container. Intended for testing. [default=false]")
|
||||||
|
fs.Uint64Var(&s.MaxOpenFiles, "max-open-files", 1000000, "Number of files that can be opened by Kubelet process. [default=1000000]")
|
||||||
}
|
}
|
||||||
|
|
||||||
// KubeletConfig returns a KubeletConfig suitable for being run, or an error if the server setup
|
// KubeletConfig returns a KubeletConfig suitable for being run, or an error if the server setup
|
||||||
@ -370,6 +373,7 @@ func (s *KubeletServer) KubeletConfig() (*KubeletConfig, error) {
|
|||||||
ManifestURLHeader: manifestURLHeader,
|
ManifestURLHeader: manifestURLHeader,
|
||||||
MasterServiceNamespace: s.MasterServiceNamespace,
|
MasterServiceNamespace: s.MasterServiceNamespace,
|
||||||
MaxContainerCount: s.MaxContainerCount,
|
MaxContainerCount: s.MaxContainerCount,
|
||||||
|
MaxOpenFiles: s.MaxOpenFiles,
|
||||||
MaxPerPodContainerCount: s.MaxPerPodContainerCount,
|
MaxPerPodContainerCount: s.MaxPerPodContainerCount,
|
||||||
MaxPods: s.MaxPods,
|
MaxPods: s.MaxPods,
|
||||||
MinimumGCAge: s.MinimumGCAge,
|
MinimumGCAge: s.MinimumGCAge,
|
||||||
@ -628,6 +632,7 @@ func SimpleKubelet(client *client.Client,
|
|||||||
ManifestURL: manifestURL,
|
ManifestURL: manifestURL,
|
||||||
MasterServiceNamespace: masterServiceNamespace,
|
MasterServiceNamespace: masterServiceNamespace,
|
||||||
MaxContainerCount: 100,
|
MaxContainerCount: 100,
|
||||||
|
MaxOpenFiles: 1024,
|
||||||
MaxPerPodContainerCount: 2,
|
MaxPerPodContainerCount: 2,
|
||||||
MaxPods: 32,
|
MaxPods: 32,
|
||||||
MinimumGCAge: minimumGCAge,
|
MinimumGCAge: minimumGCAge,
|
||||||
@ -714,6 +719,9 @@ func RunKubelet(kcfg *KubeletConfig, builder KubeletBuilder) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create kubelet: %v", err)
|
return fmt.Errorf("failed to create kubelet: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
util.ApplyRLimitForSelf(kcfg.MaxOpenFiles)
|
||||||
|
|
||||||
// process pods and exit.
|
// process pods and exit.
|
||||||
if kcfg.Runonce {
|
if kcfg.Runonce {
|
||||||
if _, err := k.RunOnce(podCfg.Updates()); err != nil {
|
if _, err := k.RunOnce(podCfg.Updates()); err != nil {
|
||||||
@ -801,6 +809,7 @@ type KubeletConfig struct {
|
|||||||
ManifestURLHeader http.Header
|
ManifestURLHeader http.Header
|
||||||
MasterServiceNamespace string
|
MasterServiceNamespace string
|
||||||
MaxContainerCount int
|
MaxContainerCount int
|
||||||
|
MaxOpenFiles uint64
|
||||||
MaxPerPodContainerCount int
|
MaxPerPodContainerCount int
|
||||||
MaxPods int
|
MaxPods int
|
||||||
MinimumGCAge time.Duration
|
MinimumGCAge time.Duration
|
||||||
|
@ -20,6 +20,7 @@ package util
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/docker/libcontainer/cgroups/fs"
|
"github.com/docker/libcontainer/cgroups/fs"
|
||||||
"github.com/docker/libcontainer/configs"
|
"github.com/docker/libcontainer/configs"
|
||||||
@ -39,3 +40,7 @@ func RunInResourceContainer(containerName string) error {
|
|||||||
|
|
||||||
return manager.Apply(os.Getpid())
|
return manager.Apply(os.Getpid())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ApplyRLimitForSelf(maxOpenFiles uint64) {
|
||||||
|
syscall.Setrlimit(syscall.RLIMIT_NOFILE, &syscall.Rlimit{Max: maxOpenFiles, Cur: maxOpenFiles})
|
||||||
|
}
|
||||||
|
@ -25,3 +25,7 @@ import (
|
|||||||
func RunInResourceContainer(containerName string) error {
|
func RunInResourceContainer(containerName string) error {
|
||||||
return errors.New("resource-only containers unsupported in this platform")
|
return errors.New("resource-only containers unsupported in this platform")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ApplyRLimitForSelf(maxOpenFiles uint64) error {
|
||||||
|
return errors.New("SetRLimit unsupported in this platform")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user