adding support for kubemark --node-labels flag

This commit is contained in:
Krzysztof Siedlecki
2019-10-10 17:06:02 +02:00
parent 8f9d9961a2
commit 4bdf48eb2a
2 changed files with 35 additions and 15 deletions

View File

@@ -134,15 +134,19 @@ func (hk *HollowKubelet) Run() {
select {}
}
// HollowKubletOptions contains settable parameters for hollow kubelet.
type HollowKubletOptions struct {
NodeName string
KubeletPort int
KubeletReadOnlyPort int
MaxPods int
PodsPerCore int
NodeLabels map[string]string
}
// Builds a KubeletConfiguration for the HollowKubelet, ensuring that the
// usual defaults are applied for fields we do not override.
func GetHollowKubeletConfig(
nodeName string,
kubeletPort int,
kubeletReadOnlyPort int,
maxPods int,
podsPerCore int) (*options.KubeletFlags, *kubeletconfig.KubeletConfiguration) {
func GetHollowKubeletConfig(opt *HollowKubletOptions) (*options.KubeletFlags, *kubeletconfig.KubeletConfiguration) {
testRootDir := utils.MakeTempDirOrDie("hollow-kubelet.", "")
podFilePath := utils.MakeTempDirOrDie("static-pods", testRootDir)
klog.Infof("Using %s as root dir for hollow-kubelet", testRootDir)
@@ -151,13 +155,13 @@ func GetHollowKubeletConfig(
f := options.NewKubeletFlags()
f.EnableServer = true
f.RootDirectory = testRootDir
f.HostnameOverride = nodeName
f.HostnameOverride = opt.NodeName
f.MinimumGCAge = metav1.Duration{Duration: 1 * time.Minute}
f.MaxContainerCount = 100
f.MaxPerPodContainerCount = 2
f.RegisterNode = true
f.RegisterSchedulable = true
f.ProviderID = fmt.Sprintf("kubemark://%v", nodeName)
f.ProviderID = fmt.Sprintf("kubemark://%v", opt.NodeName)
// Config struct
c, err := options.NewKubeletConfiguration()
@@ -167,8 +171,8 @@ func GetHollowKubeletConfig(
c.StaticPodURL = ""
c.Address = "0.0.0.0" /* bind address */
c.Port = int32(kubeletPort)
c.ReadOnlyPort = int32(kubeletReadOnlyPort)
c.Port = int32(opt.KubeletPort)
c.ReadOnlyPort = int32(opt.KubeletReadOnlyPort)
c.StaticPodPath = podFilePath
c.FileCheckFrequency.Duration = 20 * time.Second
c.HTTPCheckFrequency.Duration = 20 * time.Second
@@ -176,8 +180,8 @@ func GetHollowKubeletConfig(
c.NodeStatusReportFrequency.Duration = time.Minute
c.SyncFrequency.Duration = 10 * time.Second
c.EvictionPressureTransitionPeriod.Duration = 5 * time.Minute
c.MaxPods = int32(maxPods)
c.PodsPerCore = int32(podsPerCore)
c.MaxPods = int32(opt.MaxPods)
c.PodsPerCore = int32(opt.PodsPerCore)
c.ClusterDNS = []string{}
c.ImageGCHighThresholdPercent = 90
c.ImageGCLowThresholdPercent = 80