Skip to content

Commit

Permalink
Support-k8s-1.26 (#693)
Browse files Browse the repository at this point in the history
## 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`
  • Loading branch information
ATGardner authored May 8, 2023
1 parent f5878a2 commit 7ab21e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.1.45
VERSION=v0.1.46

OUT_DIR=dist
YEAR?=$(shell date +"%Y")
Expand Down
6 changes: 2 additions & 4 deletions pkg/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 4 additions & 6 deletions pkg/util/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"
)

Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 7ab21e9

Please sign in to comment.