Added pods-per-core to kubelet. #25762

This commit is contained in:
Robert Rati 2016-05-18 11:18:10 -04:00
parent 35922bdcbd
commit 2d487f7c06
11 changed files with 599 additions and 531 deletions

View File

@ -240,6 +240,7 @@ func startComponents(firstManifestURL, secondManifestURL string) (string, string
10*time.Second, /* OutOfDiskTransitionFrequency */ 10*time.Second, /* OutOfDiskTransitionFrequency */
10*time.Second, /* EvictionPressureTransitionPeriod */ 10*time.Second, /* EvictionPressureTransitionPeriod */
40, /* MaxPods */ 40, /* MaxPods */
0, /* PodsPerCore*/
cm, net.ParseIP("127.0.0.1")) cm, net.ParseIP("127.0.0.1"))
kubeletapp.RunKubelet(kcfg) kubeletapp.RunKubelet(kcfg)
@ -273,6 +274,7 @@ func startComponents(firstManifestURL, secondManifestURL string) (string, string
10*time.Second, /* OutOfDiskTransitionFrequency */ 10*time.Second, /* OutOfDiskTransitionFrequency */
10*time.Second, /* EvictionPressureTransitionPeriod */ 10*time.Second, /* EvictionPressureTransitionPeriod */
40, /* MaxPods */ 40, /* MaxPods */
0, /* PodsPerCore*/
cm, cm,
net.ParseIP("127.0.0.1")) net.ParseIP("127.0.0.1"))

View File

@ -146,6 +146,7 @@ func NewKubeletServer() *KubeletServer {
HairpinMode: componentconfig.PromiscuousBridge, HairpinMode: componentconfig.PromiscuousBridge,
BabysitDaemons: false, BabysitDaemons: false,
EvictionPressureTransitionPeriod: unversioned.Duration{Duration: 5 * time.Minute}, EvictionPressureTransitionPeriod: unversioned.Duration{Duration: 5 * time.Minute},
PodsPerCore: 0,
}, },
} }
} }
@ -264,4 +265,5 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&s.EvictionSoftGracePeriod, "eviction-soft-grace-period", s.EvictionSoftGracePeriod, "A set of eviction grace periods (e.g. memory.available=1m30s) that correspond to how long a soft eviction threshold must hold before triggering a pod eviction.") fs.StringVar(&s.EvictionSoftGracePeriod, "eviction-soft-grace-period", s.EvictionSoftGracePeriod, "A set of eviction grace periods (e.g. memory.available=1m30s) that correspond to how long a soft eviction threshold must hold before triggering a pod eviction.")
fs.DurationVar(&s.EvictionPressureTransitionPeriod.Duration, "eviction-pressure-transition-period", s.EvictionPressureTransitionPeriod.Duration, "Duration for which the kubelet has to wait before transitioning out of an eviction pressure condition.") fs.DurationVar(&s.EvictionPressureTransitionPeriod.Duration, "eviction-pressure-transition-period", s.EvictionPressureTransitionPeriod.Duration, "Duration for which the kubelet has to wait before transitioning out of an eviction pressure condition.")
fs.Int32Var(&s.EvictionMaxPodGracePeriod, "eviction-max-pod-grace-period", s.EvictionMaxPodGracePeriod, "Maximum allowed grace period (in seconds) to use when terminating pods in response to a soft eviction threshold being met. If negative, defer to pod specified value.") fs.Int32Var(&s.EvictionMaxPodGracePeriod, "eviction-max-pod-grace-period", s.EvictionMaxPodGracePeriod, "Maximum allowed grace period (in seconds) to use when terminating pods in response to a soft eviction threshold being met. If negative, defer to pod specified value.")
fs.Int32Var(&s.PodsPerCore, "pods-per-core", s.PodsPerCore, "Number of Pods per core that can run on this Kubelet. The total number of Pods on this Kubelet cannot exceed max-pods, so max-pods will be used if this caulcation results in a larger number of Pods allowed on the Kubelet. A value of 0 disables this limit.")
} }

View File

@ -277,6 +277,7 @@ func UnsecuredKubeletConfig(s *options.KubeletServer) (*KubeletConfig, error) {
ExperimentalFlannelOverlay: s.ExperimentalFlannelOverlay, ExperimentalFlannelOverlay: s.ExperimentalFlannelOverlay,
NodeIP: net.ParseIP(s.NodeIP), NodeIP: net.ParseIP(s.NodeIP),
EvictionConfig: evictionConfig, EvictionConfig: evictionConfig,
PodsPerCore: int(s.PodsPerCore),
}, nil }, nil
} }
@ -533,7 +534,7 @@ func SimpleKubelet(client *clientset.Clientset,
cloud cloudprovider.Interface, cloud cloudprovider.Interface,
osInterface kubecontainer.OSInterface, osInterface kubecontainer.OSInterface,
fileCheckFrequency, httpCheckFrequency, minimumGCAge, nodeStatusUpdateFrequency, syncFrequency, outOfDiskTransitionFrequency, evictionPressureTransitionPeriod time.Duration, fileCheckFrequency, httpCheckFrequency, minimumGCAge, nodeStatusUpdateFrequency, syncFrequency, outOfDiskTransitionFrequency, evictionPressureTransitionPeriod time.Duration,
maxPods int, maxPods int, podsPerCore int,
containerManager cm.ContainerManager, clusterDNS net.IP) *KubeletConfig { containerManager cm.ContainerManager, clusterDNS net.IP) *KubeletConfig {
imageGCPolicy := kubelet.ImageGCPolicy{ imageGCPolicy := kubelet.ImageGCPolicy{
HighThresholdPercent: 90, HighThresholdPercent: 90,
@ -604,6 +605,7 @@ func SimpleKubelet(client *clientset.Clientset,
Writer: &io.StdWriter{}, Writer: &io.StdWriter{},
OutOfDiskTransitionFrequency: outOfDiskTransitionFrequency, OutOfDiskTransitionFrequency: outOfDiskTransitionFrequency,
EvictionConfig: evictionConfig, EvictionConfig: evictionConfig,
PodsPerCore: podsPerCore,
} }
return &kcfg return &kcfg
} }
@ -814,6 +816,7 @@ type KubeletConfig struct {
OOMAdjuster *oom.OOMAdjuster OOMAdjuster *oom.OOMAdjuster
OSInterface kubecontainer.OSInterface OSInterface kubecontainer.OSInterface
PodCIDR string PodCIDR string
PodsPerCore int
ReconcileCIDR bool ReconcileCIDR bool
PodConfig *config.PodConfig PodConfig *config.PodConfig
PodInfraContainerImage string PodInfraContainerImage string
@ -923,6 +926,7 @@ func CreateAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod
kc.PodCIDR, kc.PodCIDR,
kc.ReconcileCIDR, kc.ReconcileCIDR,
kc.MaxPods, kc.MaxPods,
kc.PodsPerCore,
kc.NvidiaGPUs, kc.NvidiaGPUs,
kc.DockerExecHandler, kc.DockerExecHandler,
kc.ResolverConfig, kc.ResolverConfig,

View File

@ -50,6 +50,7 @@ type HollowNodeConfig struct {
const ( const (
maxPods = 110 maxPods = 110
podsPerCore = 0
) )
var knownMorphs = sets.NewString("kubelet", "proxy") var knownMorphs = sets.NewString("kubelet", "proxy")
@ -115,6 +116,7 @@ func main() {
config.KubeletReadOnlyPort, config.KubeletReadOnlyPort,
containerManager, containerManager,
maxPods, maxPods,
podsPerCore,
) )
hollowKubelet.Run() hollowKubelet.Run()
} }

View File

@ -135,6 +135,7 @@ kubelet
--outofdisk-transition-frequency=5m0s: Duration for which the kubelet has to wait before transitioning out of out-of-disk node condition status. Default: 5m0s --outofdisk-transition-frequency=5m0s: Duration for which the kubelet has to wait before transitioning out of out-of-disk node condition status. Default: 5m0s
--pod-cidr="": The CIDR to use for pod IP addresses, only used in standalone mode. In cluster mode, this is obtained from the master. --pod-cidr="": The CIDR to use for pod IP addresses, only used in standalone mode. In cluster mode, this is obtained from the master.
--pod-infra-container-image="gcr.io/google_containers/pause-amd64:3.0": The image whose network/ipc namespaces containers in each pod will use. --pod-infra-container-image="gcr.io/google_containers/pause-amd64:3.0": The image whose network/ipc namespaces containers in each pod will use.
--pods-per-core=0: Number of Pods per core that can run on this Kubelet. The total number of Pods on this Kubelet cannot exceed max-pods, so max-pods will be used if this caulcation results in a larger number of Pods allowed on the Kubelet. A value of 0 disables this limit.
--port=10250: The port for the Kubelet to serve on. --port=10250: The port for the Kubelet to serve on.
--read-only-port=10255: The read-only port for the Kubelet to serve on with no authentication/authorization (set to 0 to disable) --read-only-port=10255: The read-only port for the Kubelet to serve on with no authentication/authorization (set to 0 to disable)
--really-crash-for-testing[=false]: If true, when panics occur crash. Intended for testing. --really-crash-for-testing[=false]: If true, when panics occur crash. Intended for testing.

View File

@ -329,6 +329,7 @@ pod-cidr
pod-eviction-timeout pod-eviction-timeout
pod-infra-container-image pod-infra-container-image
pod-running pod-running
pods-per-core
policy-config-file policy-config-file
poll-interval poll-interval
portal-net portal-net

View File

@ -316,6 +316,7 @@ func DeepCopy_componentconfig_KubeletConfiguration(in KubeletConfiguration, out
return err return err
} }
out.EvictionMaxPodGracePeriod = in.EvictionMaxPodGracePeriod out.EvictionMaxPodGracePeriod = in.EvictionMaxPodGracePeriod
out.PodsPerCore = in.PodsPerCore
return nil return nil
} }

File diff suppressed because it is too large Load Diff

View File

@ -360,6 +360,8 @@ type KubeletConfiguration struct {
EvictionPressureTransitionPeriod unversioned.Duration `json:"evictionPressureTransitionPeriod,omitempty"` EvictionPressureTransitionPeriod unversioned.Duration `json:"evictionPressureTransitionPeriod,omitempty"`
// Maximum allowed grace period (in seconds) to use when terminating pods in response to a soft eviction threshold being met. // Maximum allowed grace period (in seconds) to use when terminating pods in response to a soft eviction threshold being met.
EvictionMaxPodGracePeriod int32 `json:"evictionMaxPodGracePeriod,omitempty"` EvictionMaxPodGracePeriod int32 `json:"evictionMaxPodGracePeriod,omitempty"`
// Maximum number of pods per core. Cannot exceed MaxPods
PodsPerCore int32 `json:"podsPerCore"`
} }
type KubeSchedulerConfiguration struct { type KubeSchedulerConfiguration struct {

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"math"
"net" "net"
"net/http" "net/http"
"os" "os"
@ -216,6 +217,7 @@ func NewMainKubelet(
podCIDR string, podCIDR string,
reconcileCIDR bool, reconcileCIDR bool,
maxPods int, maxPods int,
podsPerCore int,
nvidiaGPUs int, nvidiaGPUs int,
dockerExecHandler dockertools.ExecHandler, dockerExecHandler dockertools.ExecHandler,
resolverConfig string, resolverConfig string,
@ -343,6 +345,7 @@ func NewMainKubelet(
nonMasqueradeCIDR: nonMasqueradeCIDR, nonMasqueradeCIDR: nonMasqueradeCIDR,
reconcileCIDR: reconcileCIDR, reconcileCIDR: reconcileCIDR,
maxPods: maxPods, maxPods: maxPods,
podsPerCore: podsPerCore,
nvidiaGPUs: nvidiaGPUs, nvidiaGPUs: nvidiaGPUs,
syncLoopMonitor: atomic.Value{}, syncLoopMonitor: atomic.Value{},
resolverConfig: resolverConfig, resolverConfig: resolverConfig,
@ -817,6 +820,9 @@ type Kubelet struct {
// the list of handlers to call during pod sync. // the list of handlers to call during pod sync.
lifecycle.PodSyncHandlers lifecycle.PodSyncHandlers
// the number of allowed pods per core
podsPerCore int
} }
// Validate given node IP belongs to the current host // Validate given node IP belongs to the current host
@ -3048,8 +3054,13 @@ func (kl *Kubelet) setNodeStatusMachineInfo(node *api.Node) {
node.Status.NodeInfo.MachineID = info.MachineID node.Status.NodeInfo.MachineID = info.MachineID
node.Status.NodeInfo.SystemUUID = info.SystemUUID node.Status.NodeInfo.SystemUUID = info.SystemUUID
node.Status.Capacity = cadvisor.CapacityFromMachineInfo(info) node.Status.Capacity = cadvisor.CapacityFromMachineInfo(info)
if kl.podsPerCore > 0 {
node.Status.Capacity[api.ResourcePods] = *resource.NewQuantity(
int64(math.Min(float64(info.NumCores*kl.podsPerCore), float64(kl.maxPods))), resource.DecimalSI)
} else {
node.Status.Capacity[api.ResourcePods] = *resource.NewQuantity( node.Status.Capacity[api.ResourcePods] = *resource.NewQuantity(
int64(kl.maxPods), resource.DecimalSI) int64(kl.maxPods), resource.DecimalSI)
}
node.Status.Capacity[api.ResourceNvidiaGPU] = *resource.NewQuantity( node.Status.Capacity[api.ResourceNvidiaGPU] = *resource.NewQuantity(
int64(kl.nvidiaGPUs), resource.DecimalSI) int64(kl.nvidiaGPUs), resource.DecimalSI)
if node.Status.NodeInfo.BootID != "" && if node.Status.NodeInfo.BootID != "" &&

View File

@ -43,7 +43,7 @@ func NewHollowKubelet(
dockerClient dockertools.DockerInterface, dockerClient dockertools.DockerInterface,
kubeletPort, kubeletReadOnlyPort int, kubeletPort, kubeletReadOnlyPort int,
containerManager cm.ContainerManager, containerManager cm.ContainerManager,
maxPods int, maxPods int, podsPerCore int,
) *HollowKubelet { ) *HollowKubelet {
testRootDir := integration.MakeTempDirOrDie("hollow-kubelet.", "") testRootDir := integration.MakeTempDirOrDie("hollow-kubelet.", "")
manifestFilePath := integration.MakeTempDirOrDie("manifest", testRootDir) manifestFilePath := integration.MakeTempDirOrDie("manifest", testRootDir)
@ -74,6 +74,7 @@ func NewHollowKubelet(
5*time.Minute, /* OutOfDiskTransitionFrequency */ 5*time.Minute, /* OutOfDiskTransitionFrequency */
5*time.Minute, /* EvictionPressureTransitionPeriod */ 5*time.Minute, /* EvictionPressureTransitionPeriod */
maxPods, maxPods,
podsPerCore,
containerManager, containerManager,
nil, nil,
), ),