-
Notifications
You must be signed in to change notification settings - Fork 960
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
247 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
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" | ||
"sort" | ||
"strings" | ||
|
||
"github.com/PuerkitoBio/goquery" | ||
"github.com/aws/karpenter/tools/kompat/pkg/kompat" | ||
"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 | ||
fmt.Print(len(supportedEKSversions)) | ||
|
||
chart, err := kompat.Parse(outputFileName) | ||
if err != nil { | ||
log.Fatalf("unable to generate compatibility matrix") | ||
} | ||
|
||
sort.Slice(chart[0].Compatibility, func(i int, j int) bool { | ||
return chart[0].Compatibility[i].AppVersion < chart[0].Compatibility[j].AppVersion | ||
}) | ||
|
||
len := len(chart[0].Compatibility) | ||
version := strings.TrimPrefix(os.Args[1], "v") | ||
appendVersion := fmt.Sprintf( | ||
` | ||
- appVersion: %s | ||
minK8sVersion: %s | ||
maxK8sVersion: %s`, version, chart[0].Compatibility[len-1].MinK8sVersion, chart[0].Compatibility[len-1].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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/pkg/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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters