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

@@ -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