diff --git a/pkg/cluster/internal/create/create.go b/pkg/cluster/internal/create/create.go index add0df5d23..e89d789605 100644 --- a/pkg/cluster/internal/create/create.go +++ b/pkg/cluster/internal/create/create.go @@ -22,11 +22,9 @@ import ( "time" "github.com/alessio/shellescape" - "k8s.io/apimachinery/pkg/util/version" "sigs.k8s.io/kind/pkg/cluster/internal/delete" "sigs.k8s.io/kind/pkg/cluster/internal/providers" - "sigs.k8s.io/kind/pkg/cluster/nodeutils" "sigs.k8s.io/kind/pkg/errors" "sigs.k8s.io/kind/pkg/internal/apis/config" "sigs.k8s.io/kind/pkg/internal/apis/config/encoding" @@ -108,11 +106,6 @@ func Cluster(logger log.Logger, p providers.Provider, opts *ClusterOptions) erro return err } - // TODO: remove once 1.20 is EOL or we no longer want to support dual-stack in 1.20 images - if err := fixupDualStack(p, opts.Config); err != nil { - return err - } - // TODO(bentheelder): make this controllable from the command line? actionsToRun := []actions.Action{ loadbalancer.NewAction(), // setup external loadbalancer @@ -262,64 +255,3 @@ func validateProvider(p providers.Provider) error { } return nil } - -// fixupDualStack enables the Kubeadm feature gate if kubernetes version is 1.20 -// previous versions doesn't support dual-stack so it returns an error -// 1.21+ enable the feature gate by default -func fixupDualStack(p providers.Provider, cfg *config.Cluster) error { - // return early if is not dualstack - if cfg.Networking.IPFamily != config.DualStackFamily { - return nil - } - - // we need to obtain the kubernetes version from the nodes - name := cfg.Name - n, err := p.ListNodes(name) - if err != nil { - return err - } - if len(n) == 0 { - return errors.New("no nodes found") - } - // use the first control plane node available - // we validate against the apiserver version. - node, err := nodeutils.BootstrapControlPlaneNode(n) - if err != nil { - return err - } - kubeVersion, err := nodeutils.KubeVersion(node) - if err != nil { - return errors.Wrapf(err, "failed to get kubernetes version from node %s", node.String()) - } - ver, err := version.ParseSemantic(kubeVersion) - if err != nil { - return errors.Wrapf(err, "failed to parse node version %s", kubeVersion) - } - - // dual-stack is only supported in 1.20+ - if ver.LessThan(version.MustParseSemantic("v1.20.0")) { - return errors.New("failed to create cluster, dual-stack is only supported on Kubernetes versions 1.20+") - } - - // dual-stack feature gate is enabled by default since 1.21 - if ver.AtLeast(version.MustParseSemantic("v1.21.0")) { - return nil - } - - // for 1.20 we have to explicitly enable the feature gate - // we can patch kubeadm here so we avoid to plumb this hack further - dualPatch := ` -apiVersion: kubeadm.k8s.io/v1beta2 -kind: ClusterConfiguration -metadata: - name: config -featureGates: - IPv6DualStack: true -` - if len(cfg.KubeadmConfigPatches) > 0 { - cfg.KubeadmConfigPatches = append(cfg.KubeadmConfigPatches, dualPatch) - } else { - cfg.KubeadmConfigPatches = []string{dualPatch} - } - return nil -}