Skip to content

Commit

Permalink
Remove support for Canal and the vxlan Flannel backend for k8s 1.17+
Browse files Browse the repository at this point in the history
  • Loading branch information
johngmyers committed Mar 13, 2020
1 parent 1ab724e commit 6d90881
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
3 changes: 3 additions & 0 deletions docs/releases/1.17-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ the notes prior to the release).
* Since 1.16, a controller is now used to apply labels to nodes. If
you are not using AWS, GCE or OpenStack your (non-master) nodes may
not have labels applied correctly.

* As of Kubernetes 1.17 the Canal CNI and the "vxlan" backend of the Flannel CNI
are no longer supported due to [a bug in Flannel](https://github.com/coreos/flannel/issues/1243).

# Required Actions

Expand Down
1 change: 1 addition & 0 deletions pkg/apis/kops/validation/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ go_test(
deps = [
"//pkg/apis/kops:go_default_library",
"//upup/pkg/fi:go_default_library",
"//vendor/github.com/blang/semver:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/kops/validation/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ func ValidateCluster(c *kops.Cluster, strict bool) field.ErrorList {
}
}

allErrs = append(allErrs, newValidateCluster(c)...)
allErrs = append(allErrs, newValidateCluster(c, kubernetesRelease)...)

return allErrs
}
Expand Down
27 changes: 18 additions & 9 deletions pkg/apis/kops/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func ValidateDockerConfig(config *kops.DockerConfig, fldPath *field.Path) field.
return allErrs
}

func newValidateCluster(cluster *kops.Cluster) field.ErrorList {
func newValidateCluster(cluster *kops.Cluster, kubernetesRelease semver.Version) field.ErrorList {
allErrs := validation.ValidateObjectMeta(&cluster.ObjectMeta, false, validation.NameIsDNSSubdomain, field.NewPath("metadata"))
allErrs = append(allErrs, validateClusterSpec(&cluster.Spec, field.NewPath("spec"))...)
allErrs = append(allErrs, validateClusterSpec(&cluster.Spec, kubernetesRelease, field.NewPath("spec"))...)

// Additional cloud-specific validation rules
switch kops.CloudProviderID(cluster.Spec.CloudProvider) {
Expand All @@ -56,7 +56,7 @@ func newValidateCluster(cluster *kops.Cluster) field.ErrorList {
return allErrs
}

func validateClusterSpec(spec *kops.ClusterSpec, fieldPath *field.Path) field.ErrorList {
func validateClusterSpec(spec *kops.ClusterSpec, kubernetesRelease semver.Version, fieldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}

allErrs = append(allErrs, validateSubnets(spec.Subnets, fieldPath.Child("subnets"))...)
Expand Down Expand Up @@ -97,7 +97,7 @@ func validateClusterSpec(spec *kops.ClusterSpec, fieldPath *field.Path) field.Er
}

if spec.Networking != nil {
allErrs = append(allErrs, validateNetworking(spec, spec.Networking, fieldPath.Child("networking"))...)
allErrs = append(allErrs, validateNetworking(spec, spec.Networking, kubernetesRelease, fieldPath.Child("networking"))...)
if spec.Networking.Calico != nil {
allErrs = append(allErrs, validateNetworkingCalico(spec.Networking.Calico, spec.EtcdClusters[0], fieldPath.Child("networking", "calico"))...)
}
Expand Down Expand Up @@ -290,7 +290,7 @@ func validateKubeAPIServer(v *kops.KubeAPIServerConfig, fldPath *field.Path) fie
return allErrs
}

func validateNetworking(c *kops.ClusterSpec, v *kops.NetworkingSpec, fldPath *field.Path) field.ErrorList {
func validateNetworking(c *kops.ClusterSpec, v *kops.NetworkingSpec, kubernetesRelease semver.Version, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
optionTaken := false

Expand Down Expand Up @@ -336,7 +336,7 @@ func validateNetworking(c *kops.ClusterSpec, v *kops.NetworkingSpec, fldPath *fi
}
optionTaken = true

allErrs = append(allErrs, validateNetworkingFlannel(v.Flannel, fldPath.Child("flannel"))...)
allErrs = append(allErrs, validateNetworkingFlannel(v.Flannel, kubernetesRelease, fldPath.Child("flannel"))...)
}

if v.Calico != nil {
Expand All @@ -352,7 +352,11 @@ func validateNetworking(c *kops.ClusterSpec, v *kops.NetworkingSpec, fldPath *fi
}
optionTaken = true

allErrs = append(allErrs, validateNetworkingCanal(v.Canal, fldPath.Child("canal"))...)
if kubernetesRelease.GTE(semver.MustParse("1.17.0")) {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("canal"), "Canal CNI is not supported as of Kubernetes 1.17"))
} else {
allErrs = append(allErrs, validateNetworkingCanal(v.Canal, fldPath.Child("canal"))...)
}
}

if v.Kuberouter != nil {
Expand Down Expand Up @@ -412,13 +416,18 @@ func validateNetworking(c *kops.ClusterSpec, v *kops.NetworkingSpec, fldPath *fi
return allErrs
}

func validateNetworkingFlannel(v *kops.FlannelNetworkingSpec, fldPath *field.Path) field.ErrorList {
func validateNetworkingFlannel(v *kops.FlannelNetworkingSpec, kubernetesRelease semver.Version, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}

supported := []string{"udp"}
if kubernetesRelease.LT(semver.MustParse("1.17.0")) {
supported = append(supported, "vxlan")
}

if v.Backend == "" {
allErrs = append(allErrs, field.Required(fldPath.Child("backend"), "Flannel backend must be specified"))
} else {
allErrs = append(allErrs, IsValidValue(fldPath.Child("backend"), &v.Backend, []string{"udp", "vxlan"})...)
allErrs = append(allErrs, IsValidValue(fldPath.Child("backend"), &v.Backend, supported)...)
}

return allErrs
Expand Down
5 changes: 3 additions & 2 deletions pkg/apis/kops/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package validation
import (
"testing"

"github.com/blang/semver"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation"
Expand Down Expand Up @@ -286,7 +287,7 @@ func Test_Validate_Networking_Flannel(t *testing.T) {
cluster := &kops.Cluster{}
cluster.Spec.Networking = networking

errs := validateNetworking(&cluster.Spec, networking, field.NewPath("networking"))
errs := validateNetworking(&cluster.Spec, networking, semver.MustParse("1.16.0"), field.NewPath("networking"))
testErrors(t, g.Input, errs, g.ExpectedErrors)
}
}
Expand Down Expand Up @@ -336,7 +337,7 @@ func Test_Validate_AdditionalPolicies(t *testing.T) {
{Name: "subnet1"},
},
}
errs := validateClusterSpec(clusterSpec, field.NewPath("spec"))
errs := validateClusterSpec(clusterSpec, semver.MustParse("1.16.0"), field.NewPath("spec"))
testErrors(t, g.Input, errs, g.ExpectedErrors)
}
}
Expand Down

0 comments on commit 6d90881

Please sign in to comment.