Skip to content

Commit

Permalink
chore: support kube-scheduler config version
Browse files Browse the repository at this point in the history
Support kube-scheduler config version.

Signed-off-by: Noel Georgi <[email protected]>
  • Loading branch information
frezbo committed Nov 10, 2023
1 parent 68bf392 commit fa05430
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions kubernetes/compatibility/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ func (v Version) FeatureFlagSeccompDefaultEnabledByDefault() bool {
// see https://github.com/kubernetes/kubernetes/pull/110805
return semver.Version(v).GTE(semver.Version{Major: 1, Minor: 25})
}

// KubeSchedulerConfigurationAPIVersion returns the API version of the kube-scheduler configuration.
func (v Version) KubeSchedulerConfigurationAPIVersion() string {
// https://v1-25.docs.kubernetes.io/docs/reference/scheduling/config/
// v1.25 and above supports v1
if semver.Version(v).GTE(semver.Version{Major: 1, Minor: 25}) {
return "kubescheduler.config.k8s.io/v1"
}

// see https://v1-24.docs.kubernetes.io/docs/reference/scheduling/config/
return "kubescheduler.config.k8s.io/v1beta3"
}
6 changes: 5 additions & 1 deletion kubernetes/compatibility/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import (
)

func TestFeatures(t *testing.T) {
for _, test := range []struct {
for _, test := range []struct { //nolint:govet
versions []compatibility.Version

expectedSupportsKubeletConfigContainerRuntimeEndpoint bool
expectedFeatureFlagSeccompDefaultEnabledByDefault bool
expectedKubeSchedulerConfigurationAPIVersion string
}{
{
versions: []compatibility.Version{
Expand All @@ -26,6 +27,7 @@ func TestFeatures(t *testing.T) {

expectedSupportsKubeletConfigContainerRuntimeEndpoint: false,
expectedFeatureFlagSeccompDefaultEnabledByDefault: false,
expectedKubeSchedulerConfigurationAPIVersion: "kubescheduler.config.k8s.io/v1beta3",
},
{
versions: []compatibility.Version{
Expand All @@ -34,6 +36,7 @@ func TestFeatures(t *testing.T) {
},
expectedSupportsKubeletConfigContainerRuntimeEndpoint: false,
expectedFeatureFlagSeccompDefaultEnabledByDefault: true,
expectedKubeSchedulerConfigurationAPIVersion: "kubescheduler.config.k8s.io/v1",
},
{
versions: []compatibility.Version{
Expand All @@ -44,6 +47,7 @@ func TestFeatures(t *testing.T) {
},
expectedSupportsKubeletConfigContainerRuntimeEndpoint: true,
expectedFeatureFlagSeccompDefaultEnabledByDefault: true,
expectedKubeSchedulerConfigurationAPIVersion: "kubescheduler.config.k8s.io/v1",
},
} {
for _, version := range test.versions {
Expand Down

0 comments on commit fa05430

Please sign in to comment.