From 7ab21e996ae4dea43066614c59bab774d4eb9c28 Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Mon, 8 May 2023 12:00:18 +0300 Subject: [PATCH] Support-k8s-1.26 (#693) ## What allow installation on k8s `1.26.x` (previously we allowed only up to `1.25.x`) no other code changes required to support `1.26` ## Why EKS has 1.26 available, and i'm sure other cloud providers as well ## Notes improved k8s version check to use semver semantics for `1.21-0 - 1.26-0` --- Makefile | 2 +- pkg/store/store.go | 6 ++---- pkg/util/kube/kube.go | 10 ++++------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 5cbfe0d1..dabd96d2 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=v0.1.45 +VERSION=v0.1.46 OUT_DIR=dist YEAR?=$(shell date +"%Y") diff --git a/pkg/store/store.go b/pkg/store/store.go index 39865aa0..f8371db9 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -145,8 +145,7 @@ type Store struct { NetworkTesterImage string TCPConnectionTesterGenerateName string TCPConnectionTesterName string - MinKubeVersion string - MaxKubeVersion string + KubeVersionConstrint *semver.Constraints MasterIngressName string ClusterResourcesPath string InClusterPath string @@ -265,8 +264,7 @@ func init() { s.NetworkTesterImage = "quay.io/codefresh/cf-venona-network-tester:latest" s.TCPConnectionTesterGenerateName = "cf-tcp-connections-tester-" s.TCPConnectionTesterName = "cf-tcp-connections-tester" - s.MinKubeVersion = "v1.21.0" - s.MaxKubeVersion = "v1.25.999" + s.KubeVersionConstrint, _ = semver.NewConstraint("1.21-0 - 1.26-0") s.MasterIngressName = "-master" s.ClusterResourcesPath = "/bootstrap/cluster-resources.yaml" s.InClusterPath = "/bootstrap/cluster-resources/in-cluster" diff --git a/pkg/util/kube/kube.go b/pkg/util/kube/kube.go index bb81c747..b7422a9d 100644 --- a/pkg/util/kube/kube.go +++ b/pkg/util/kube/kube.go @@ -23,6 +23,7 @@ import ( "strings" "time" + "github.com/Masterminds/semver/v3" "github.com/codefresh-io/cli-v2/pkg/log" "github.com/codefresh-io/cli-v2/pkg/store" @@ -36,7 +37,6 @@ import ( k8serrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/version" "k8s.io/client-go/kubernetes" ) @@ -91,11 +91,9 @@ func EnsureClusterRequirements(ctx context.Context, opts ClusterRequirementsOpti return fmt.Errorf("failed to check the cluster's version: %w", err) } - minDelta := version.CompareKubeAwareVersionStrings(store.Get().MinKubeVersion, kubeVersion.String()) - maxDelta := version.CompareKubeAwareVersionStrings(store.Get().MaxKubeVersion, kubeVersion.String()) - - if minDelta < 0 || maxDelta > 0 { - return fmt.Errorf("%s: cluster's server version must be between %s and %s", requirementsValidationErrorMessage, store.Get().MinKubeVersion, store.Get().MaxKubeVersion) + v := semver.MustParse(kubeVersion.String()) + if !store.Get().KubeVersionConstrint.Check(v) { + return fmt.Errorf("%s: cluster's server version must match %s", requirementsValidationErrorMessage, store.Get().KubeVersionConstrint) } req := validationRequest{