From 74b6b723821f8f5b7291fba72d58be5794d2f770 Mon Sep 17 00:00:00 2001 From: pixiake Date: Fri, 25 Aug 2023 15:59:19 +0800 Subject: [PATCH] Fix hybridnet configuration bug Signed-off-by: pixiake --- cmd/kk/apis/kubekey/v1alpha2/network_types.go | 2 +- cmd/kk/pkg/plugins/network/tasks.go | 4 ++++ cmd/kk/pkg/plugins/network/templates/hybridnet.go | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/kk/apis/kubekey/v1alpha2/network_types.go b/cmd/kk/apis/kubekey/v1alpha2/network_types.go index 0fe7f8ab1..4a9ed3747 100644 --- a/cmd/kk/apis/kubekey/v1alpha2/network_types.go +++ b/cmd/kk/apis/kubekey/v1alpha2/network_types.go @@ -170,7 +170,7 @@ func (n *NetworkConfig) EnableMultusCNI() bool { // EnableIPV4POOL_NAT_OUTGOING is used to determine whether to enable CALICO_IPV4POOL_NAT_OUTGOING. func (c *CalicoCfg) EnableIPV4POOL_NAT_OUTGOING() bool { if c.Ipv4NatOutgoing == nil { - return false + return true } return *c.Ipv4NatOutgoing } diff --git a/cmd/kk/pkg/plugins/network/tasks.go b/cmd/kk/pkg/plugins/network/tasks.go index 68824b39c..cd3cf3419 100644 --- a/cmd/kk/pkg/plugins/network/tasks.go +++ b/cmd/kk/pkg/plugins/network/tasks.go @@ -375,6 +375,10 @@ func (d *DeployHybridnet) Execute(runtime connector.Runtime) error { cmd = fmt.Sprintf("%s --set daemon.enableNetworkPolicy=false", cmd) } + if d.KubeConf.Cluster.Network.Hybridnet.DefaultNetworkType != "" { + cmd = fmt.Sprintf("%s --set defaultNetworkType=%s", cmd, d.KubeConf.Cluster.Network.Hybridnet.DefaultNetworkType) + } + if d.KubeConf.Cluster.Network.Hybridnet.PreferBGPInterfaces != "" { cmd = fmt.Sprintf("%s --set daemon.preferBGPInterfaces=%s", cmd, d.KubeConf.Cluster.Network.Hybridnet.PreferBGPInterfaces) } diff --git a/cmd/kk/pkg/plugins/network/templates/hybridnet.go b/cmd/kk/pkg/plugins/network/templates/hybridnet.go index 03b3b1035..5a39e9cb2 100644 --- a/cmd/kk/pkg/plugins/network/templates/hybridnet.go +++ b/cmd/kk/pkg/plugins/network/templates/hybridnet.go @@ -72,7 +72,7 @@ spec: {{- end }} {{- if .ExcludeIPs }} excludeIPs: -{{ toYaml .ReservedIPs | indent 4 }} +{{ toYaml .ExcludeIPs | indent 4 }} {{- end }} {{- end }} {{- end }}