-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
list all currently supported Kubernetes versions #13775
Merged
spowelljr
merged 5 commits into
kubernetes:master
from
prezha:list-supported-k8s-versions
May 27, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
Copyright 2022 The Kubernetes Authors All rights reserved. | ||
|
||
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 config | ||
|
||
import ( | ||
"context" | ||
"sort" | ||
|
||
"github.com/google/go-github/v43/github" | ||
"golang.org/x/mod/semver" | ||
"k8s.io/minikube/pkg/minikube/constants" | ||
) | ||
|
||
// supportedKubernetesVersions returns reverse-sort supported Kubernetes releases from GitHub that are in [constants.OldestKubernetesVersion, constants.NewestKubernetesVersion] range, including prereleases. | ||
// in case it cannot get it from GitHub, in addition to [constants.NewestKubernetesVersion, constants.OldestKubernetesVersion], 'constants.DefaultKubernetesVersion' is also returned if different from 'constants.NewestKubernetesVersion'. | ||
func supportedKubernetesVersions() (releases []string) { | ||
minver := constants.OldestKubernetesVersion | ||
defver := constants.DefaultKubernetesVersion | ||
maxver := constants.NewestKubernetesVersion | ||
|
||
ghc := github.NewClient(nil) | ||
|
||
opts := &github.ListOptions{PerPage: 100} | ||
for (opts.Page+1)*100 <= 300 { | ||
rls, resp, err := ghc.Repositories.ListReleases(context.Background(), "kubernetes", "kubernetes", opts) | ||
if err != nil { | ||
v := []string{maxver} | ||
if defver != maxver { | ||
v = append(v, defver) | ||
} | ||
v = append(v, minver) | ||
return v | ||
} | ||
for _, rl := range rls { | ||
ver := rl.GetTagName() | ||
if !semver.IsValid(ver) { | ||
continue | ||
} | ||
// skip out-of-range versions | ||
if (minver != "" && semver.Compare(minver, ver) == 1) || (maxver != "" && semver.Compare(ver, maxver) == 1) { | ||
continue | ||
} | ||
releases = append(releases, ver) | ||
} | ||
if resp.NextPage == 0 { | ||
break | ||
} | ||
opts.Page = resp.NextPage | ||
} | ||
sort.Slice(releases, func(i, j int) bool { return semver.Compare(releases[i], releases[j]) == 1 }) | ||
return releases | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prezha one of the use cases of this feature would be in the minikube GUI, when we load the page to create a cluster we can list all supported kubernetes versions, this will make a http call (not very cheap) in the gui.
i suggest this code to only reference the constants and if needed add some sort of automation (in Makefile) to generate this list. instead of making the call each single time.
is that reasonable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@medyagh that's a good use case as well
this func (exposed via CLI) takes ~1.7sec to produce a fresh list of all currently acceptable k8s versions, which indeed is not that cheap
now, the release cadence for minikube is ~monthly, whereas k8s (supporting the last 3 of its minor versions) has it more frequently, and therefore we/user could end up with the outdated static list (especially if a user did not upgrade to the latest minikube version)
i'd suggest keeping this func/cli functionality as-is in this pr, and for the GUI use case, we could ship minikube releases with a "hardcoded" list of all supported k8s versions (known at the time of the release) and also have eg, a "Refresh" link/button nearby to call this func again so that the GUI can regenerate and cache results for later reuse?
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the person working on the GUI, on GUI startup we could make a call to this function and cache the result. So by the time the user gets around to starting the cluster with a custom k8s version, the list will already be cached and will be able to validate the users input with no latency. I'm not arguing the solution either way, but stating that I don't believe this will impact the GUI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spowelljr yes, thanks, that sounds like a good/optimal solution to me
@medyagh would you agree then that we keep this func[tionality] as-is in this pr and Steven will call it as needed and also cache results on the gui side?