mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +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
|
||||
ProxierSyncPeriod time.Duration
|
||||
ProxierMinSyncPeriod time.Duration
|
||||
NodeLabels map[string]string
|
||||
}
|
||||
|
||||
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.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.")
|
||||
bindableNodeLabels := cliflag.ConfigurationMap(c.NodeLabels)
|
||||
fs.Var(&bindableNodeLabels, "node-labels", "Additional node labels")
|
||||
}
|
||||
|
||||
func (c *hollowNodeConfig) createClientConfigFromFile() (*restclient.Config, error) {
|
||||
@ -104,6 +107,17 @@ func (c *hollowNodeConfig) createClientConfigFromFile() (*restclient.Config, err
|
||||
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() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
@ -125,7 +139,9 @@ func main() {
|
||||
|
||||
// newControllerManagerCommand creates a *cobra.Command object with default parameters
|
||||
func newHollowNodeCommand() *cobra.Command {
|
||||
s := &hollowNodeConfig{}
|
||||
s := &hollowNodeConfig{
|
||||
NodeLabels: make(map[string]string),
|
||||
}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "kubemark",
|
||||
@ -160,7 +176,7 @@ func run(config *hollowNodeConfig) {
|
||||
}
|
||||
|
||||
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.Timeout = c.NodeStatusUpdateFrequency.Duration
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user