From abc6ea34d4c7977938c661c0eb9fb0d896fa1a5e Mon Sep 17 00:00:00 2001 From: Amanuel Engeda Date: Sun, 6 Aug 2023 23:25:35 -0700 Subject: [PATCH] Matrix --- Makefile | 5 +- cmd/controller/main.go | 19 ++++++ go.mod | 7 +++ go.sum | 16 +++++ hack/code/version_compatibility.go | 69 +++++++++++++++++++++ hack/compatibility-karpenter.yaml | 32 ++++++++++ hack/docgen.sh | 14 +++++ hack/docs/compatibilitymetrix_gen_docs.go | 68 ++++++++++++++++++++ pkg/apis/crds/karpenter.sh_nodepools.yaml | 40 ++++++------ tools/kompat/README.md | 2 +- tools/kompat/{ => cmd/kompat}/main.go | 8 ++- tools/kompat/kompat.go | 2 +- website/content/en/preview/upgrade-guide.md | 18 ++++++ 13 files changed, 271 insertions(+), 29 deletions(-) create mode 100644 hack/code/version_compatibility.go create mode 100644 hack/compatibility-karpenter.yaml create mode 100755 hack/docgen.sh create mode 100644 hack/docs/compatibilitymetrix_gen_docs.go rename tools/kompat/{ => cmd/kompat}/main.go (96%) diff --git a/Makefile b/Makefile index 0eea2816ae43..031239718e0c 100644 --- a/Makefile +++ b/Makefile @@ -153,10 +153,7 @@ delete: ## Delete the controller from your ~/.kube/config cluster helm uninstall karpenter --namespace karpenter docgen: ## Generate docs - go run hack/docs/metrics_gen_docs.go pkg/ $(KARPENTER_CORE_DIR)/pkg website/content/en/preview/concepts/metrics.md - go run hack/docs/instancetypes_gen_docs.go website/content/en/preview/concepts/instance-types.md - go run hack/docs/configuration_gen_docs.go website/content/en/preview/concepts/settings.md - cd charts/karpenter && helm-docs + $(WITH_GOFLAGS) ./hack/docgen.sh codegen: ## Auto generate files based on AWS APIs response $(WITH_GOFLAGS) ./hack/codegen.sh diff --git a/cmd/controller/main.go b/cmd/controller/main.go index 0146572b9f2c..13ea665f8214 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -16,6 +16,11 @@ package main import ( "github.com/samber/lo" + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/types" + "knative.dev/pkg/logging" + + "github.com/aws/karpenter/tools/kompat" "github.com/aws/karpenter/pkg/cloudprovider" "github.com/aws/karpenter/pkg/controllers" @@ -43,6 +48,20 @@ func main() { lo.Must0(op.AddHealthzCheck("cloud-provider", awsCloudProvider.LivenessProbe)) cloudProvider := metrics.Decorate(awsCloudProvider) + cm := &v1.ConfigMap{} + if err := op.GetClient().Get(ctx, types.NamespacedName{Name: "karpenter-global-settings"}, cm); err != nil { + logging.FromContext(ctx).Error(err) + } + + k8sVersion, err := op.AMIProvider.KubeServerVersion(ctx) + if err != nil { + logging.FromContext(ctx).Error(err) + } + err = kompat.IsCompatible("hack/compatibility-karpenter.yaml", cm.Labels["app.kubernetes.io/version"], k8sVersion) + if err != nil { + logging.FromContext(ctx).Error(err) + } + op. WithControllers(ctx, corecontrollers.NewControllers( ctx, diff --git a/go.mod b/go.mod index af17c310ebf2..f92b3f651c9c 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/avast/retry-go v3.0.0+incompatible github.com/aws/aws-sdk-go v1.44.328 github.com/aws/karpenter-core v0.30.0 + github.com/aws/karpenter/tools/kompat v0.0.0-20230908153250-0563f1e909dd github.com/imdario/mergo v0.3.16 github.com/mitchellh/hashstructure/v2 v2.0.2 github.com/onsi/ginkgo/v2 v2.11.0 @@ -32,6 +33,7 @@ require ( require ( contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect contrib.go.opencensus.io/exporter/prometheus v0.4.0 // indirect + github.com/Masterminds/semver/v3 v3.2.1 // indirect github.com/andybalholm/cascadia v1.3.1 // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -64,20 +66,25 @@ require ( github.com/google/uuid v1.3.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kelseyhightower/envconfig v1.4.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/mattn/go-runewidth v0.0.9 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_model v0.4.0 // indirect github.com/prometheus/common v0.42.0 // indirect github.com/prometheus/procfs v0.10.1 // indirect github.com/prometheus/statsd_exporter v0.21.0 // indirect + github.com/spf13/cobra v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect go.opencensus.io v0.24.0 // indirect go.uber.org/atomic v1.9.0 // indirect diff --git a/go.sum b/go.sum index 3baa07bbad21..efed5394ea94 100644 --- a/go.sum +++ b/go.sum @@ -37,6 +37,8 @@ contrib.go.opencensus.io/exporter/prometheus v0.4.0/go.mod h1:o7cosnyfuPVK0tB8q0 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= +github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/Pallinder/go-randomdata v1.2.0 h1:DZ41wBchNRb/0GfsePLiSwb0PHZmT67XY00lCDlaYPg= github.com/Pallinder/go-randomdata v1.2.0/go.mod h1:yHmJgulpD2Nfrm0cR9tI/+oAgRqCQQixsA8HyRZfV9Y= github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM= @@ -55,6 +57,8 @@ github.com/aws/aws-sdk-go v1.44.328 h1:WBwlf8ym9SDQ/GTIBO9eXyvwappKJyOetWJKl4mT7 github.com/aws/aws-sdk-go v1.44.328/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/karpenter-core v0.30.0 h1:iEn5D/mvaqPeYNix7JPZyuyELf5Qu2Fx2WP8lFByhDo= github.com/aws/karpenter-core v0.30.0/go.mod h1:AQl8m8OtgO2N8IlZlzAU6MTrJTJSbe6K4GwdRUNSJVc= +github.com/aws/karpenter/tools/kompat v0.0.0-20230908153250-0563f1e909dd h1:0O0COO3v9ZdQiQCh4XInB1cicKPzaUPCZWICHdQbhyQ= +github.com/aws/karpenter/tools/kompat v0.0.0-20230908153250-0563f1e909dd/go.mod h1:l/TIBsaCx/IrOr0Xvlj/cHLOf05QzuQKEZ1hx2XWmfU= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -77,6 +81,7 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -210,6 +215,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= +github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= +github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -245,9 +252,13 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -261,6 +272,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= @@ -305,11 +318,14 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM= github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/spf13/cobra v1.6.0 h1:42a0n6jwCot1pUmomAp4T7DeMD+20LFv4Q54pxLf2LI= +github.com/spf13/cobra v1.6.0/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= diff --git a/hack/code/version_compatibility.go b/hack/code/version_compatibility.go new file mode 100644 index 000000000000..f68eafa12262 --- /dev/null +++ b/hack/code/version_compatibility.go @@ -0,0 +1,69 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "fmt" + "log" + "net/http" + "os" + "strings" + + "github.com/PuerkitoBio/goquery" + "github.com/samber/lo" +) + +var uri = "https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html" +var outputFileName = "hack/compatibility-karpenter.yaml" + +func main() { + if len(os.Args) != 2 { + log.Fatalf("Usage: %s karpenter version", os.Args[0]) + } + if os.Args[1] == "no tag" { + log.Printf("No version") + os.Exit(0) + } + response := lo.Must(http.Get(uri)) + defer response.Body.Close() + + doc := lo.Must(goquery.NewDocumentFromReader(response.Body)) + supportedEKSversions := doc.Find("ul").Eq(0).Find("li").Find("p").Find("code").Nodes + + // flag for the kompat tool for number of k8s version needed + fmt.Print(len(supportedEKSversions)) + minK8sVersion := supportedEKSversions[len(supportedEKSversions)-1].FirstChild.Data + maxK8sVersion := supportedEKSversions[0].FirstChild.Data + + version := strings.TrimSuffix(strings.TrimPrefix(os.Args[1], "v"), "0") + "x" + appendVersion := fmt.Sprintf( + ` + - appVersion: %s + minK8sVersion: %s + maxK8sVersion: %s`, version, minK8sVersion, maxK8sVersion) + + yamlFile, err := os.ReadFile(outputFileName) + if err != nil { + log.Printf("Can't read %s file: %v", os.Args[1], err) + os.Exit(2) + } + + log.Println("writing output to", outputFileName) + f, err := os.Create(outputFileName) + if err != nil { + log.Fatalf("unable to open %s to write generated output: %v", outputFileName, err) + } + f.WriteString(string(yamlFile) + appendVersion) +} diff --git a/hack/compatibility-karpenter.yaml b/hack/compatibility-karpenter.yaml new file mode 100644 index 000000000000..fedbba2be9e5 --- /dev/null +++ b/hack/compatibility-karpenter.yaml @@ -0,0 +1,32 @@ +name: "karpenter" +compatibility: + - appVersion: 0.21.x + minK8sVersion: 1.21 + maxK8sVersion: 1.24 + - appVersion: 0.22.x + minK8sVersion: 1.21 + maxK8sVersion: 1.24 + - appVersion: 0.23.x + minK8sVersion: 1.21 + maxK8sVersion: 1.24 + - appVersion: 0.24.x + minK8sVersion: 1.21 + maxK8sVersion: 1.24 + - appVersion: 0.25.x + minK8sVersion: 1.21 + maxK8sVersion: 1.25 + - appVersion: 0.26.x + minK8sVersion: 1.21 + maxK8sVersion: 1.25 + - appVersion: 0.27.x + minK8sVersion: 1.21 + maxK8sVersion: 1.25 + - appVersion: 0.28.x + minK8sVersion: 1.23 + maxK8sVersion: 1.27 + - appVersion: 0.29.x + minK8sVersion: 1.23 + maxK8sVersion: 1.27 + - appVersion: 0.30.x + minK8sVersion: 1.23 + maxK8sVersion: 1.27 \ No newline at end of file diff --git a/hack/docgen.sh b/hack/docgen.sh new file mode 100755 index 000000000000..a7d7ad9ae4a1 --- /dev/null +++ b/hack/docgen.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -euo pipefail + +compatibilitymatrix() { + supportedVersion=$(go run hack/code/version_compatibility.go "$(git describe --exact-match --tags || echo "no tag")") + go run hack/docs/compatibilitymetrix_gen_docs.go website/content/en/preview/upgrade-guide.md hack/compatibility-karpenter.yaml $supportedVersion +} + + +compatibilitymatrix +go run hack/docs/metrics_gen_docs.go pkg/ $(KARPENTER_CORE_DIR)/pkg website/content/en/preview/concepts/metrics.md +go run hack/docs/instancetypes_gen_docs.go website/content/en/preview/concepts/instance-types.md +go run hack/docs/configuration_gen_docs.go website/content/en/preview/concepts/settings.md +cd charts/karpenter && helm-docs \ No newline at end of file diff --git a/hack/docs/compatibilitymetrix_gen_docs.go b/hack/docs/compatibilitymetrix_gen_docs.go new file mode 100644 index 000000000000..3ccaae1a910d --- /dev/null +++ b/hack/docs/compatibilitymetrix_gen_docs.go @@ -0,0 +1,68 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "fmt" + "log" + "os" + "strconv" + "strings" + + "github.com/aws/karpenter/tools/kompat" +) + +func main() { + outputFileName := os.Args[1] + mdFile, err := os.ReadFile(outputFileName) + if err != nil { + log.Printf("Can't read %s file: %v", os.Args[1], err) + os.Exit(2) + } + + genStart := "[comment]: <> (the content below is generated from hack/docs/compataiblitymetrix_gen_docs.go)" + genEnd := "[comment]: <> (end docs generated content from hack/docs/compataiblitymetrix_gen_docs.go)" + startDocSections := strings.Split(string(mdFile), genStart) + if len(startDocSections) != 2 { + log.Fatalf("expected one generated comment block start but got %d", len(startDocSections)-1) + } + endDocSections := strings.Split(string(mdFile), genEnd) + if len(endDocSections) != 2 { + log.Fatalf("expected one generated comment block end but got %d", len(endDocSections)-1) + } + topDoc := fmt.Sprintf("%s%s\n\n", startDocSections[0], genStart) + bottomDoc := fmt.Sprintf("\n%s%s", genEnd, endDocSections[1]) + + baseText, err := kompat.Parse(os.Args[2]) + if err != nil { + log.Fatalf("unable to generate compatibility matrix") + } + var supportedVersions int + if len(os.Args) == 4 { + supportedVersions, err = strconv.Atoi(os.Args[3]) + if err != nil { + log.Fatalf("unable to get supported number of versons") + } + } else { + supportedVersions = 5 + } + + log.Println("writing output to", outputFileName) + f, err := os.Create(outputFileName) + if err != nil { + log.Fatalf("unable to open %s to write generated output: %v", outputFileName, err) + } + f.WriteString(topDoc + baseText.Markdown(kompat.Options{LastN: supportedVersions}) + bottomDoc) +} diff --git a/pkg/apis/crds/karpenter.sh_nodepools.yaml b/pkg/apis/crds/karpenter.sh_nodepools.yaml index eeacb0cb0641..f1b0c2305d45 100644 --- a/pkg/apis/crds/karpenter.sh_nodepools.yaml +++ b/pkg/apis/crds/karpenter.sh_nodepools.yaml @@ -51,37 +51,37 @@ spec: Node properties are determined from a combination of provisioner and pod scheduling constraints. properties: - deprovisioning: + disruption: default: + consolidateAfter: 15s consolidationPolicy: WhenUnderutilized - consolidationTTL: 15s - expirationTTL: 90d - description: Deprovisioning contains the parameters that relate to - Karpenter's deprovisioning logic + expireAfter: 720h + description: Disruption contains the parameters that relate to Karpenter's + disruption logic properties: + consolidateAfter: + default: 15s + description: ConsolidateAfter is the duration the controller will + wait before attempting to terminate nodes that are underutilized. + Refer to ConsolidationPolicy for how underutilization is considered. + pattern: ^(([0-9]+(s|m|h))+)|(Never)$ + type: string consolidationPolicy: default: WhenUnderutilized description: ConsolidationPolicy describes which nodes Karpenter - can deprovision through its consolidation algorithm. This policy + can disrupt through its consolidation algorithm. This policy defaults to "WhenUnderutilized" if not specified enum: - - Never - WhenEmpty - WhenUnderutilized type: string - consolidationTTL: - default: 15s - description: ConsolidationTTL is the duration the controller will - wait before attempting to terminate nodes that are underutilized. - Refer to ConsolidationPolicy for how underutilization is considered. - type: string - expirationTTL: - default: 90d - description: ExpirationTTL is the duration the controller will - wait before terminating a node, measured from when the node - is created. This is useful to implement features like eventually - consistent node upgrade, memory leak protection, and disruption - testing. + expireAfter: + default: 720h + description: ExpireAfter is the duration the controller will wait + before terminating a node, measured from when the node is created. + This is useful to implement features like eventually consistent + node upgrade, memory leak protection, and disruption testing. + pattern: ^(([0-9]+(s|m|h))+)|(Never)$ type: string type: object limits: diff --git a/tools/kompat/README.md b/tools/kompat/README.md index 77df016b539a..b67be6111633 100644 --- a/tools/kompat/README.md +++ b/tools/kompat/README.md @@ -5,7 +5,7 @@ Kompat is a simple CLI tool to interact with `compatibility.yaml` files which ho ## Installation ``` -go install github.com/aws/karpenter/tools/kompat +go install github.com/aws/karpenter/tools/kompat/cmd/kompat ``` ## Usage: diff --git a/tools/kompat/main.go b/tools/kompat/cmd/kompat/main.go similarity index 96% rename from tools/kompat/main.go rename to tools/kompat/cmd/kompat/main.go index 15d35e3f5f23..f65f073ae3df 100644 --- a/tools/kompat/main.go +++ b/tools/kompat/cmd/kompat/main.go @@ -26,6 +26,8 @@ import ( "github.com/olekukonko/tablewriter" "github.com/samber/lo" "github.com/spf13/cobra" + + "github.com/aws/karpenter/tools/kompat" ) const ( @@ -60,14 +62,14 @@ var ( Args: cobra.ArbitraryArgs, Run: func(cmd *cobra.Command, args []string) { if rootOpts.Branch != "" { - DefaultGithubBranch = rootOpts.Branch + kompat.DefaultGithubBranch = rootOpts.Branch } - kompatList, err := Parse(args...) + kompatList, err := kompat.Parse(args...) if err != nil { fmt.Printf("Unable to parse kompat file: %v\n", err) os.Exit(1) } - opts := Options{ + opts := kompat.Options{ LastN: rootOpts.LastNVersions, Version: rootOpts.K8sVersion, } diff --git a/tools/kompat/kompat.go b/tools/kompat/kompat.go index ae78084a4f67..47492cabd828 100644 --- a/tools/kompat/kompat.go +++ b/tools/kompat/kompat.go @@ -12,7 +12,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package kompat import ( "bytes" diff --git a/website/content/en/preview/upgrade-guide.md b/website/content/en/preview/upgrade-guide.md index 1843ac8b525b..be43698e536c 100644 --- a/website/content/en/preview/upgrade-guide.md +++ b/website/content/en/preview/upgrade-guide.md @@ -11,6 +11,24 @@ Use your existing upgrade mechanisms to upgrade your core add-ons in Kubernetes To make upgrading easier we aim to minimize introduction of breaking changes with the followings: +## Compatibility Matrix + +[comment]: <> (the content below is generated from hack/docs/compataiblitymetrix_gen_docs.go) + +| KUBERNETES | 1.23 | 1.24 | 1.25 | 1.26 | 1.27 | +|------------|---------|---------|---------|---------|---------| +| karpenter | 0.21.x+ | 0.21.x+ | 0.25.x+ | 0.28.x+ | 0.28.x+ | + +[comment]: <> (end docs generated content from hack/docs/compataiblitymetrix_gen_docs.go) + +{{% alert title="Note" color="warning" %}} +Karpenter currently does not support the following [new `topologySpreadConstraints` keys](https://kubernetes.io/blog/2023/04/17/fine-grained-pod-topology-spread-features-beta/), promoted to beta in Kubernetes 1.27: +- `matchLabelKeys` +- `nodeAffinityPolicy` +- `nodeTaintsPolicy` + +For more information on Karpenter's support for these keys, view [this tracking issue](https://github.com/aws/karpenter-core/issues/430). +{{% /alert %}} ## Compatibility issues To make upgrading easier, we aim to minimize the introduction of breaking changes with the followings components: