diff --git a/docs/pages/deploying-vclusters/compat-matrix.mdx b/docs/pages/deploying-vclusters/compat-matrix.mdx index cc7ec0b48..c84effe2c 100644 --- a/docs/pages/deploying-vclusters/compat-matrix.mdx +++ b/docs/pages/deploying-vclusters/compat-matrix.mdx @@ -1,22 +1,82 @@ -## 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: -| Vcluster Distro | k8s Host version | Distro Version | -| --------------- | ---------------- | -------------------- | -| eks | 1.28 | v1.28.2-eks-1-28-6 | -| | 1.27 | v1.27.6-eks-1-27-13 | -| | 1.26 | v1.26.9-eks-1-26-19 | -| | 1.25 | v1.25.14-eks-1-25-23 | -| k0s | 1.28 | v1.28.2-k0s.0 | -| | 1.26 | v1.26.9-k0s.0 | -| | 1.27 | v1.27.6-k0s.0 | -| | 1.25 | v1.25.14-k0s.0 | -| k3s | 1.28 | v1.28.2-k3s1 | -| | 1.27 | v1.27.6-k3s1 | -| | 1.26 | v1.26.9-k3s1 | -| | 1.25 | v1.25.14-k3s1 | -| k8s | 1.28 | v1.28.2 | -| | 1.27 | v1.27.6 | -| | 1.26 | v1.26.9 | -| | 1.25 | v1.25.14 | +| DISTRO VERSION | V1.29.0-K3S1 | V1.28.5-K3S1 | V1.27.9-K3S1 | V1.26.12-K3S1 | +| HOST VERSION | | | | | +|----------------|--------------|--------------|--------------|---------------| +| 1.29 | recommended | + | ! | + | +| 1.28 | + | recommended | ! | + | +| 1.27 | + | + | recommended | + | +| 1.26 | + | + | + | recommended | + + +Legend: + +! : known issue + ++ : likely compatible + ++-------------------------+------------------+---------------------------+ +| VCLUSTER DISTRO VERSION | HOST K8S VERSION | KNOWN ISSUES | ++-------------------------+------------------+---------------------------+ +| v1.27.9-k3s1 | 1.28 | there is some issue there | +| v1.27.9-k3s1 | 1.29 | there is some issue there | ++-------------------------+------------------+---------------------------+ +## Compatibility Matrix for k8s distro + +The following table provides a compatibility matrix of which k8s version are supported aginst which vcluster distro versions: + +| DISTRO VERSION | V1.29.0 | V1.28.4 | V1.27.8 | V1.26.11 | +| HOST VERSION | | | | | +|----------------|-------------|-------------|-------------|-------------| +| 1.29 | recommended | + | + | + | +| 1.28 | + | recommended | + | + | +| 1.27 | + | + | recommended | + | +| 1.26 | + | + | + | recommended | + + +Legend: + +! : known issue + ++ : 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: + +| DISTRO VERSION | V1.29.1-K0S 0 | V1.28.2-K0S 0 | V1.27.6-K0S 0 | V1.26.9-K0S 0 | +| HOST VERSION | | | | | +|----------------|---------------|---------------|---------------|---------------| +| 1.29 | recommended | + | + | + | +| 1.28 | + | recommended | + | + | +| 1.27 | + | + | recommended | + | +| 1.26 | + | + | + | recommended | + + +Legend: + +! : known issue + ++ : 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: + +| DISTRO VERSION | 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 | +| HOST VERSION | | | | | +|----------------|--------------------|---------------------|---------------------|----------------------| +| 1.28 | recommended | + | + | + | +| 1.27 | + | recommended | + | + | +| 1.26 | + | + | recommended | + | +| 1.25 | + | + | + | recommended | + + +Legend: + +! : known issue + ++ : likely compatible + diff --git a/hack/compat-matrix/main.go b/hack/compat-matrix/main.go index c9c5e588d..a4e2e232c 100644 --- a/hack/compat-matrix/main.go +++ b/hack/compat-matrix/main.go @@ -3,59 +3,162 @@ package main import ( "bytes" _ "embed" + "fmt" "os" - "path/filepath" "slices" "strings" "github.com/olekukonko/tablewriter" + "gopkg.in/yaml.v2" "github.com/loft-sh/vcluster-values/values" "golang.org/x/exp/maps" ) //go:embed matrix-template.tmpl -var template []byte +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() { - buff := &bytes.Buffer{} - _, _ = buff.Write(template) - table := tablewriter.NewWriter(buff) - table.SetHeader([]string{"Vcluster Distro", "k8s Host version", "Distro version"}) - updateTableWithDistro(table, "k3s", values.K3SVersionMap) - updateTableWithDistro(table, "k0s", values.K0SVersionMap) - updateTableWithDistro(table, "k8s", values.K8SAPIVersionMap) - updateTableWithDistro(table, "eks", values.EKSAPIVersionMap) - table.SetAlignment(tablewriter.ALIGN_LEFT) - table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false}) - table.SetCenterSeparator("|") - table.Render() - rendered := buff.Bytes() + knowIssuesBytes, err := os.ReadFile("known_issues.yaml") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + //issues := KnownIssues{K3s: map[string]issueList{"1.28": {"rancher/k3s:v1.29.0-k3s1": "some issue"}}} + issues := KnownIssues{} + err = yaml.UnmarshalStrict(knowIssuesBytes, &issues) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + currentFile, err := os.ReadFile(os.Args[1]) if err != nil { os.Stderr.WriteString(err.Error()) os.Exit(1) } - if !slices.Equal(rendered, currentFile) { - err := os.WriteFile(os.Args[1], rendered, 644) - if err != nil { - os.Stderr.WriteString(err.Error()) - os.Exit(1) + renderedBytes := &bytes.Buffer{} + buff := updateTableWithDistro("k3s", values.K3SVersionMap, issues) + renderedBytes.WriteString(fmt.Sprintf(templateString, "k3s", buff.String())) + renderedBytes.WriteString(createKnownIssue(issues.K3s)) + buff.Reset() + buff = updateTableWithDistro("k8s", values.K8SAPIVersionMap, issues) + renderedBytes.WriteString(fmt.Sprintf(templateString, "k8s", buff.String())) + renderedBytes.WriteString(createKnownIssue(issues.K8s)) + buff.Reset() + buff = updateTableWithDistro("k0s", values.K0SVersionMap, issues) + renderedBytes.WriteString(fmt.Sprintf(templateString, "k0s", buff.String())) + renderedBytes.WriteString(createKnownIssue(issues.K0s)) + buff.Reset() + buff = updateTableWithDistro("eks", values.EKSAPIVersionMap, issues) + renderedBytes.WriteString(fmt.Sprintf(templateString, "eks", buff.String())) + renderedBytes.WriteString(createKnownIssue(issues.Eks)) + buff.Reset() + + if !slices.Equal(currentFile, renderedBytes.Bytes()) { + os.WriteFile(os.Args[1], renderedBytes.Bytes(), 0644) + 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{"distro version\nhost version"}, 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 updateTableWithDistro(table *tablewriter.Table, distroName string, versionMap map[string]string) { - keys := maps.Keys(versionMap) +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 i, v := range keys { - name := "" - if i == 0 { - name = distroName + for _, hostVersion := range keys { + for vclusterVersion, issue := range issues[hostVersion] { + table.Append([]string{vclusterVersion, hostVersion, issue}) } - versionTag := filepath.Base(versionMap[v]) - lastColon := strings.LastIndex(versionTag, ":") - table.Append([]string{name, v, versionTag[lastColon+1:]}) } + table.Render() + 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 = "!" + } else if i == lineNumber { + char = "recommended" + } else { + char = "+" + } + line = append(line, char) + } + return line +} + +func removeRegistry(vclusterApiVersion string) string { + lastColon := strings.LastIndex(vclusterApiVersion, ":") + if lastColon == -1 { + return vclusterApiVersion + } + return vclusterApiVersion[lastColon+1:] } diff --git a/hack/compat-matrix/matrix-template.tmpl b/hack/compat-matrix/matrix-template.tmpl index 18aab1bbd..97a3be47e 100644 --- a/hack/compat-matrix/matrix-template.tmpl +++ b/hack/compat-matrix/matrix-template.tmpl @@ -1,4 +1,12 @@ -## Compatibility Matrix +## 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: + +! : known issue + ++ : likely compatible +