-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added compatibility matrix generation
- Loading branch information
1 parent
63a8e2b
commit d0dc953
Showing
10 changed files
with
331 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Matrix compatibility | ||
|
||
on: | ||
release: | ||
types: [created] | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
go-unit-test: | ||
name: Generate the compatibility matrix | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v4 | ||
- name: Set up Go 1.21 | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: "go.mod" | ||
cache: false | ||
- name: run compat | ||
run: go run hack/compat-matrix/main.go validate docs/pages/deploying-vclusters/compat-matrix.mdx |
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,85 @@ | ||
--- | ||
title: Compatibility Matrix | ||
sidebar_label: Compatibility Matrix | ||
--- | ||
|
||
## Compatibility Matrix for k3s distro | ||
|
||
The following table provides a compatibility matrix of which k8s version are supported aginst which vcluster distro versions: | ||
|
||
| | V1.29.0-K3S1 | V1.28.5-K3S1 | V1.27.9-K3S1 | V1.26.12-K3S1 | | ||
|------|--------------------|--------------------|--------------------|--------------------| | ||
| 1.29 | :white_check_mark: | :ok: | :ok: | :ok: | | ||
| 1.28 | :ok: | :white_check_mark: | :ok: | :ok: | | ||
| 1.27 | :ok: | :ok: | :white_check_mark: | :ok: | | ||
| 1.26 | :ok: | :ok: | :ok: | :white_check_mark: | | ||
|
||
|
||
Legend: | ||
|
||
:warning: : known issue | ||
|
||
:white_check_mark: : recommended | ||
|
||
:ok: : likely compatible | ||
|
||
## Compatibility Matrix for k8s distro | ||
|
||
The following table provides a compatibility matrix of which k8s version are supported aginst which vcluster distro versions: | ||
|
||
| | V1.29.0 | V1.28.4 | V1.27.8 | V1.26.11 | | ||
|------|--------------------|--------------------|--------------------|--------------------| | ||
| 1.29 | :white_check_mark: | :ok: | :ok: | :ok: | | ||
| 1.28 | :ok: | :white_check_mark: | :ok: | :ok: | | ||
| 1.27 | :ok: | :ok: | :white_check_mark: | :ok: | | ||
| 1.26 | :ok: | :ok: | :ok: | :white_check_mark: | | ||
|
||
|
||
Legend: | ||
|
||
:warning: : known issue | ||
|
||
:white_check_mark: : recommended | ||
|
||
:ok: : likely compatible | ||
|
||
## Compatibility Matrix for k0s distro | ||
|
||
The following table provides a compatibility matrix of which k8s version are supported aginst which vcluster distro versions: | ||
|
||
| | V1.29.1-K0S 0 | V1.28.2-K0S 0 | V1.27.6-K0S 0 | V1.26.9-K0S 0 | | ||
|------|--------------------|--------------------|--------------------|--------------------| | ||
| 1.29 | :white_check_mark: | :ok: | :ok: | :ok: | | ||
| 1.28 | :ok: | :white_check_mark: | :ok: | :ok: | | ||
| 1.27 | :ok: | :ok: | :white_check_mark: | :ok: | | ||
| 1.26 | :ok: | :ok: | :ok: | :white_check_mark: | | ||
|
||
|
||
Legend: | ||
|
||
:warning: : known issue | ||
|
||
:white_check_mark: : recommended | ||
|
||
:ok: : likely compatible | ||
|
||
## Compatibility Matrix for eks distro | ||
|
||
The following table provides a compatibility matrix of which k8s version are supported aginst which vcluster distro versions: | ||
|
||
| | V1.28.2-EKS-1-28-6 | V1.27.6-EKS-1-27-13 | V1.26.9-EKS-1-26-19 | V1.25.14-EKS-1-25-23 | | ||
|------|--------------------|---------------------|---------------------|----------------------| | ||
| 1.28 | :white_check_mark: | :ok: | :ok: | :ok: | | ||
| 1.27 | :ok: | :white_check_mark: | :ok: | :ok: | | ||
| 1.26 | :ok: | :ok: | :white_check_mark: | :ok: | | ||
| 1.25 | :ok: | :ok: | :ok: | :white_check_mark: | | ||
|
||
|
||
Legend: | ||
|
||
:warning: : known issue | ||
|
||
:white_check_mark: : recommended | ||
|
||
:ok: : likely compatible | ||
|
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,188 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
_ "embed" | ||
"fmt" | ||
"os" | ||
"slices" | ||
"strings" | ||
|
||
"github.com/olekukonko/tablewriter" | ||
"gopkg.in/yaml.v2" | ||
|
||
"github.com/loft-sh/vcluster-values/values" | ||
"golang.org/x/exp/maps" | ||
) | ||
|
||
const header = `--- | ||
title: Compatibility Matrix | ||
sidebar_label: Compatibility Matrix | ||
--- | ||
` | ||
|
||
//go:embed matrix-template.tmpl | ||
var templateString string | ||
|
||
type issueList map[string]string | ||
|
||
type KnownIssues struct { | ||
K3s map[string]issueList | ||
K0s map[string]issueList | ||
K8s map[string]issueList | ||
Eks map[string]issueList | ||
} | ||
|
||
func main() { | ||
if len(os.Args) != 3 { | ||
os.Stderr.WriteString("usage: compat-matrix generate/validate outputfile") | ||
os.Exit(1) | ||
} | ||
knowIssuesBytes, err := os.ReadFile("known_issues.yaml") | ||
if err != nil { | ||
os.Stderr.WriteString(err.Error()) | ||
os.Exit(1) | ||
} | ||
issues := KnownIssues{} | ||
err = yaml.UnmarshalStrict(knowIssuesBytes, &issues) | ||
if err != nil { | ||
os.Stderr.WriteString(err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
renderedBytes := &bytes.Buffer{} | ||
renderedBytes.WriteString(header) | ||
for _, v := range []string{"k3s", "k8s", "k0s", "eks"} { | ||
var versionMap map[string]string | ||
switch v { | ||
case "k3s": | ||
versionMap = values.K3SVersionMap | ||
case "k8s": | ||
versionMap = values.K8SAPIVersionMap | ||
case "k0s": | ||
versionMap = values.K0SVersionMap | ||
case "eks": | ||
versionMap = values.EKSAPIVersionMap | ||
} | ||
buff := updateTableWithDistro(v, versionMap, issues) | ||
renderedBytes.WriteString(fmt.Sprintf(templateString, v, buff.String())) | ||
renderedBytes.WriteString(createKnownIssue(issues.K3s)) | ||
buff.Reset() | ||
} | ||
|
||
switch os.Args[1] { | ||
case "generate": | ||
err = os.WriteFile(os.Args[2], renderedBytes.Bytes(), 0644) | ||
if err != nil { | ||
os.Stderr.WriteString(err.Error()) | ||
os.Exit(1) | ||
} | ||
case "validate": | ||
currentFile, err := os.ReadFile(os.Args[2]) | ||
if err != nil { | ||
os.Stderr.WriteString(err.Error()) | ||
os.Exit(1) | ||
} | ||
if !slices.Equal(currentFile, renderedBytes.Bytes()) { | ||
os.Stderr.WriteString("compatibility matrix is not up to date, please update it by running `just validate-compat-matrix`") | ||
os.Exit(1) | ||
} | ||
} | ||
} | ||
|
||
func updateTableWithDistro(distroName string, versionMap map[string]string, knownIssues KnownIssues) *bytes.Buffer { | ||
hostVersions := maps.Keys(versionMap) | ||
vclusterAPIs := maps.Values(versionMap) | ||
slices.Sort(hostVersions) | ||
slices.Reverse(hostVersions) | ||
slices.Sort(vclusterAPIs) | ||
slices.Reverse(vclusterAPIs) | ||
|
||
buff := &bytes.Buffer{} | ||
table := tablewriter.NewWriter(buff) | ||
for i, v := range vclusterAPIs { | ||
vclusterAPIs[i] = removeRegistry(v) | ||
} | ||
table.SetHeader(append([]string{""}, vclusterAPIs...)) | ||
|
||
var issues map[string]issueList | ||
switch distroName { | ||
case "k3s": | ||
issues = knownIssues.K3s | ||
case "k0s": | ||
issues = knownIssues.K0s | ||
case "k8s": | ||
issues = knownIssues.K8s | ||
case "eks": | ||
issues = knownIssues.Eks | ||
} | ||
|
||
for hostVersion, issueList := range issues { | ||
for vclusterAPI, issueDesc := range issueList { | ||
issues[hostVersion][removeRegistry(vclusterAPI)] = issueDesc | ||
if removeRegistry(vclusterAPI) != vclusterAPI { | ||
// avoids removing valid entries | ||
delete(issues[hostVersion], vclusterAPI) | ||
} | ||
} | ||
} | ||
|
||
for i, v := range hostVersions { | ||
table.Append(createLine(v, issues[v], vclusterAPIs, i)) | ||
} | ||
|
||
table.SetAlignment(tablewriter.ALIGN_LEFT) | ||
table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false}) | ||
table.SetCenterSeparator("|") | ||
table.Render() | ||
|
||
return buff | ||
} | ||
|
||
func createKnownIssue(issues map[string]issueList) string { | ||
if len(issues) == 0 { | ||
return "" | ||
} | ||
keys := maps.Keys(issues) | ||
slices.Sort(keys) | ||
buff := &bytes.Buffer{} | ||
table := tablewriter.NewWriter(buff) | ||
table.SetHeader([]string{"vCluster Distro Version", "Host K8s Version", "Known Issues"}) | ||
|
||
for _, hostVersion := range keys { | ||
for vclusterVersion, issue := range issues[hostVersion] { | ||
table.Append([]string{vclusterVersion, hostVersion, issue}) | ||
} | ||
} | ||
table.Render() | ||
if buff.Len() > 0 { | ||
buff.WriteString("\n") | ||
} | ||
return buff.String() | ||
} | ||
|
||
func createLine(version string, list issueList, vclusterAPIVersion []string, lineNumber int) []string { | ||
line := make([]string, 1, len(vclusterAPIVersion)+1) | ||
line[0] = version | ||
for i, v := range vclusterAPIVersion { | ||
char := "" | ||
if list[v] != "" { | ||
char = ":warning" | ||
} else if i == lineNumber { | ||
char = ":white_check_mark:" | ||
} else { | ||
char = ":ok:" | ||
} | ||
line = append(line, char) | ||
} | ||
return line | ||
} | ||
|
||
func removeRegistry(vclusterAPIVersion string) string { | ||
lastColon := strings.LastIndex(vclusterAPIVersion, ":") | ||
if lastColon == -1 { | ||
return vclusterAPIVersion | ||
} | ||
return vclusterAPIVersion[lastColon+1:] | ||
} |
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 @@ | ||
## Compatibility Matrix for %s distro | ||
|
||
The following table provides a compatibility matrix of which k8s version are supported aginst which vcluster distro versions: | ||
|
||
%s | ||
|
||
Legend: | ||
|
||
:warning: : known issue | ||
|
||
:white_check_mark: : recommended | ||
|
||
:ok: : likely compatible | ||
|
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,5 @@ | ||
#k3s: | ||
# 1.29: | ||
# rancher/k3s:v1.27.9-k3s1: there is some issue there | ||
# 1.28: | ||
# rancher/k3s:v1.27.9-k3s1: there is some issue there |
Oops, something went wrong.