From d558787f98d01fb69d2e538a80f489fe668f92f0 Mon Sep 17 00:00:00 2001 From: iwilltry42 Date: Thu, 27 Jan 2022 17:11:44 +0100 Subject: [PATCH] fail on hostaliases in hostnetwork mode --- cmd/cluster/clusterCreate.go | 2 -- pkg/config/validate.go | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/cluster/clusterCreate.go b/cmd/cluster/clusterCreate.go index b7d934783a..8db5527b4c 100644 --- a/cmd/cluster/clusterCreate.go +++ b/cmd/cluster/clusterCreate.go @@ -601,7 +601,6 @@ func applyCLIOverrides(cfg conf.SimpleConfig) (conf.SimpleConfig, error) { // --host-alias hostAliasFlags := ppViper.GetStringSlice("hostaliases") - l.Log().Debugf("HostAliasFlags: %+v", hostAliasFlags) if len(hostAliasFlags) > 0 { for _, ha := range hostAliasFlags { @@ -631,7 +630,6 @@ func applyCLIOverrides(cfg conf.SimpleConfig) (conf.SimpleConfig, error) { }) } } - l.Log().Debugf("HostAliases: %+v", cfg.HostAliases) return cfg, nil } diff --git a/pkg/config/validate.go b/pkg/config/validate.go index 9d23fdd658..6572a58836 100644 --- a/pkg/config/validate.go +++ b/pkg/config/validate.go @@ -76,6 +76,11 @@ func ValidateClusterConfig(ctx context.Context, runtime runtimes.Runtime, config } } + // hostAliases not allowed in hostnetwork mode + if len(config.ClusterCreateOpts.HostAliases) > 0 && config.Cluster.Network.Name == "host" { + return fmt.Errorf("hostAliases not allowed in hostnetwork mode") + } + // validate nodes one by one for _, node := range config.Cluster.Nodes {