mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
adding support for kubemark --node-labels flag
This commit is contained in:
parent
8f9d9961a2
commit
4bdf48eb2a
@ -65,6 +65,7 @@ type hollowNodeConfig struct {
|
|||||||
UseRealProxier bool
|
UseRealProxier bool
|
||||||
ProxierSyncPeriod time.Duration
|
ProxierSyncPeriod time.Duration
|
||||||
ProxierMinSyncPeriod time.Duration
|
ProxierMinSyncPeriod time.Duration
|
||||||
|
NodeLabels map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -87,6 +88,8 @@ func (c *hollowNodeConfig) addFlags(fs *pflag.FlagSet) {
|
|||||||
fs.BoolVar(&c.UseRealProxier, "use-real-proxier", true, "Set to true if you want to use real proxier inside hollow-proxy.")
|
fs.BoolVar(&c.UseRealProxier, "use-real-proxier", true, "Set to true if you want to use real proxier inside hollow-proxy.")
|
||||||
fs.DurationVar(&c.ProxierSyncPeriod, "proxier-sync-period", 30*time.Second, "Period that proxy rules are refreshed in hollow-proxy.")
|
fs.DurationVar(&c.ProxierSyncPeriod, "proxier-sync-period", 30*time.Second, "Period that proxy rules are refreshed in hollow-proxy.")
|
||||||
fs.DurationVar(&c.ProxierMinSyncPeriod, "proxier-min-sync-period", 0, "Minimum period that proxy rules are refreshed in hollow-proxy.")
|
fs.DurationVar(&c.ProxierMinSyncPeriod, "proxier-min-sync-period", 0, "Minimum period that proxy rules are refreshed in hollow-proxy.")
|
||||||
|
bindableNodeLabels := cliflag.ConfigurationMap(c.NodeLabels)
|
||||||
|
fs.Var(&bindableNodeLabels, "node-labels", "Additional node labels")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *hollowNodeConfig) createClientConfigFromFile() (*restclient.Config, error) {
|
func (c *hollowNodeConfig) createClientConfigFromFile() (*restclient.Config, error) {
|
||||||
@ -104,6 +107,17 @@ func (c *hollowNodeConfig) createClientConfigFromFile() (*restclient.Config, err
|
|||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *hollowNodeConfig) createHollowKubeletOptions() *kubemark.HollowKubletOptions {
|
||||||
|
return &kubemark.HollowKubletOptions{
|
||||||
|
NodeName: c.NodeName,
|
||||||
|
KubeletPort: c.KubeletPort,
|
||||||
|
KubeletReadOnlyPort: c.KubeletReadOnlyPort,
|
||||||
|
MaxPods: maxPods,
|
||||||
|
PodsPerCore: podsPerCore,
|
||||||
|
NodeLabels: c.NodeLabels,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
|
||||||
@ -125,7 +139,9 @@ func main() {
|
|||||||
|
|
||||||
// newControllerManagerCommand creates a *cobra.Command object with default parameters
|
// newControllerManagerCommand creates a *cobra.Command object with default parameters
|
||||||
func newHollowNodeCommand() *cobra.Command {
|
func newHollowNodeCommand() *cobra.Command {
|
||||||
s := &hollowNodeConfig{}
|
s := &hollowNodeConfig{
|
||||||
|
NodeLabels: make(map[string]string),
|
||||||
|
}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "kubemark",
|
Use: "kubemark",
|
||||||
@ -160,7 +176,7 @@ func run(config *hollowNodeConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if config.Morph == "kubelet" {
|
if config.Morph == "kubelet" {
|
||||||
f, c := kubemark.GetHollowKubeletConfig(config.NodeName, config.KubeletPort, config.KubeletReadOnlyPort, maxPods, podsPerCore)
|
f, c := kubemark.GetHollowKubeletConfig(config.createHollowKubeletOptions())
|
||||||
|
|
||||||
heartbeatClientConfig := *clientConfig
|
heartbeatClientConfig := *clientConfig
|
||||||
heartbeatClientConfig.Timeout = c.NodeStatusUpdateFrequency.Duration
|
heartbeatClientConfig.Timeout = c.NodeStatusUpdateFrequency.Duration
|
||||||
|
@ -134,15 +134,19 @@ func (hk *HollowKubelet) Run() {
|
|||||||
select {}
|
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
|
// Builds a KubeletConfiguration for the HollowKubelet, ensuring that the
|
||||||
// usual defaults are applied for fields we do not override.
|
// usual defaults are applied for fields we do not override.
|
||||||
func GetHollowKubeletConfig(
|
func GetHollowKubeletConfig(opt *HollowKubletOptions) (*options.KubeletFlags, *kubeletconfig.KubeletConfiguration) {
|
||||||
nodeName string,
|
|
||||||
kubeletPort int,
|
|
||||||
kubeletReadOnlyPort int,
|
|
||||||
maxPods int,
|
|
||||||
podsPerCore int) (*options.KubeletFlags, *kubeletconfig.KubeletConfiguration) {
|
|
||||||
|
|
||||||
testRootDir := utils.MakeTempDirOrDie("hollow-kubelet.", "")
|
testRootDir := utils.MakeTempDirOrDie("hollow-kubelet.", "")
|
||||||
podFilePath := utils.MakeTempDirOrDie("static-pods", testRootDir)
|
podFilePath := utils.MakeTempDirOrDie("static-pods", testRootDir)
|
||||||
klog.Infof("Using %s as root dir for hollow-kubelet", testRootDir)
|
klog.Infof("Using %s as root dir for hollow-kubelet", testRootDir)
|
||||||
@ -151,13 +155,13 @@ func GetHollowKubeletConfig(
|
|||||||
f := options.NewKubeletFlags()
|
f := options.NewKubeletFlags()
|
||||||
f.EnableServer = true
|
f.EnableServer = true
|
||||||
f.RootDirectory = testRootDir
|
f.RootDirectory = testRootDir
|
||||||
f.HostnameOverride = nodeName
|
f.HostnameOverride = opt.NodeName
|
||||||
f.MinimumGCAge = metav1.Duration{Duration: 1 * time.Minute}
|
f.MinimumGCAge = metav1.Duration{Duration: 1 * time.Minute}
|
||||||
f.MaxContainerCount = 100
|
f.MaxContainerCount = 100
|
||||||
f.MaxPerPodContainerCount = 2
|
f.MaxPerPodContainerCount = 2
|
||||||
f.RegisterNode = true
|
f.RegisterNode = true
|
||||||
f.RegisterSchedulable = true
|
f.RegisterSchedulable = true
|
||||||
f.ProviderID = fmt.Sprintf("kubemark://%v", nodeName)
|
f.ProviderID = fmt.Sprintf("kubemark://%v", opt.NodeName)
|
||||||
|
|
||||||
// Config struct
|
// Config struct
|
||||||
c, err := options.NewKubeletConfiguration()
|
c, err := options.NewKubeletConfiguration()
|
||||||
@ -167,8 +171,8 @@ func GetHollowKubeletConfig(
|
|||||||
|
|
||||||
c.StaticPodURL = ""
|
c.StaticPodURL = ""
|
||||||
c.Address = "0.0.0.0" /* bind address */
|
c.Address = "0.0.0.0" /* bind address */
|
||||||
c.Port = int32(kubeletPort)
|
c.Port = int32(opt.KubeletPort)
|
||||||
c.ReadOnlyPort = int32(kubeletReadOnlyPort)
|
c.ReadOnlyPort = int32(opt.KubeletReadOnlyPort)
|
||||||
c.StaticPodPath = podFilePath
|
c.StaticPodPath = podFilePath
|
||||||
c.FileCheckFrequency.Duration = 20 * time.Second
|
c.FileCheckFrequency.Duration = 20 * time.Second
|
||||||
c.HTTPCheckFrequency.Duration = 20 * time.Second
|
c.HTTPCheckFrequency.Duration = 20 * time.Second
|
||||||
@ -176,8 +180,8 @@ func GetHollowKubeletConfig(
|
|||||||
c.NodeStatusReportFrequency.Duration = time.Minute
|
c.NodeStatusReportFrequency.Duration = time.Minute
|
||||||
c.SyncFrequency.Duration = 10 * time.Second
|
c.SyncFrequency.Duration = 10 * time.Second
|
||||||
c.EvictionPressureTransitionPeriod.Duration = 5 * time.Minute
|
c.EvictionPressureTransitionPeriod.Duration = 5 * time.Minute
|
||||||
c.MaxPods = int32(maxPods)
|
c.MaxPods = int32(opt.MaxPods)
|
||||||
c.PodsPerCore = int32(podsPerCore)
|
c.PodsPerCore = int32(opt.PodsPerCore)
|
||||||
c.ClusterDNS = []string{}
|
c.ClusterDNS = []string{}
|
||||||
c.ImageGCHighThresholdPercent = 90
|
c.ImageGCHighThresholdPercent = 90
|
||||||
c.ImageGCLowThresholdPercent = 80
|
c.ImageGCLowThresholdPercent = 80
|
||||||
|
Loading…
Reference in New Issue
Block a user