Skip to content
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

chore: add authorization config api version #23

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions kubernetes/compatibility/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ func (v Version) FeatureFlagSeccompDefaultEnabledByDefault() bool {
return semver.Version(v).GTE(semver.Version{Major: 1, Minor: 25})
}

// KubeSchedulerConfigurationAPIVersion returns the API version of the kube-scheduler configuration.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not used in talos anymore

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"
}

// KubeSchedulerHealthLivenessEndpoint returns the liveness endpoint for the kube-scheduler health check.
func (v Version) KubeSchedulerHealthLivenessEndpoint() string {
// https://github.com/kubernetes/kubernetes/pull/118148
Expand Down Expand Up @@ -81,3 +69,15 @@ func (v Version) FeatureFlagStructuredAuthorizationConfigurationEnabledByDefault
// v1.30 and above enables structured authorization configuration by default
return semver.Version(v).GTE(semver.Version{Major: 1, Minor: 30})
}

// KubeAPIServerAuthorizationConfigAPIVersion returns the API version of the kube-apiserver authorization config.
func (v Version) KubeAPIServerAuthorizationConfigAPIVersion() string {
// https://v1-30.docs.kubernetes.io/docs/reference/access-authn-authz/authorization/#using-configuration-file-for-authorization
// v1.30 and above supports v1beta1
if semver.Version(v).GTE(semver.Version{Major: 1, Minor: 30}) {
return "apiserver.config.k8s.io/v1beta1"
}

// see https://v1-29.docs.kubernetes.io/docs/reference/access-authn-authz/authorization/#configuring-the-api-server-using-an-authorization-config-file
return "apiserver.config.k8s.io/v1alpha1"
}
12 changes: 4 additions & 8 deletions kubernetes/compatibility/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func TestFeatures(t *testing.T) {
expectedFeatureFlagSeccompDefaultEnabledByDefault bool
expectedKubeAPIServerSupportsAuthorizationConfigFile bool
expectedFeatureFlagStructuredAuthorizationConfigurationEnabledByDefault bool
expectedKubeSchedulerConfigurationAPIVersion string
expectedKubeSchedulerLivenessEndpoint string
expectedKubeSchedulerReadinessEndpoint string
expectedKubeSchedulerStartupEndpoint string
expectedKubeAPIServerAuthorizationConfigAPIVersion string
}{
{
versions: []compatibility.Version{
Expand All @@ -34,7 +34,6 @@ func TestFeatures(t *testing.T) {
expectedFeatureFlagSeccompDefaultEnabledByDefault: false,
expectedKubeAPIServerSupportsAuthorizationConfigFile: false,
expectedFeatureFlagStructuredAuthorizationConfigurationEnabledByDefault: false,
expectedKubeSchedulerConfigurationAPIVersion: "kubescheduler.config.k8s.io/v1beta3",
expectedKubeSchedulerLivenessEndpoint: "/healthz",
expectedKubeSchedulerReadinessEndpoint: "/healthz",
expectedKubeSchedulerStartupEndpoint: "/healthz",
Expand All @@ -48,7 +47,6 @@ func TestFeatures(t *testing.T) {
expectedFeatureFlagSeccompDefaultEnabledByDefault: true,
expectedKubeAPIServerSupportsAuthorizationConfigFile: false,
expectedFeatureFlagStructuredAuthorizationConfigurationEnabledByDefault: false,
expectedKubeSchedulerConfigurationAPIVersion: "kubescheduler.config.k8s.io/v1",
expectedKubeSchedulerLivenessEndpoint: "/healthz",
expectedKubeSchedulerReadinessEndpoint: "/healthz",
expectedKubeSchedulerStartupEndpoint: "/healthz",
Expand All @@ -62,7 +60,6 @@ func TestFeatures(t *testing.T) {
expectedFeatureFlagSeccompDefaultEnabledByDefault: true,
expectedKubeAPIServerSupportsAuthorizationConfigFile: false,
expectedFeatureFlagStructuredAuthorizationConfigurationEnabledByDefault: false,
expectedKubeSchedulerConfigurationAPIVersion: "kubescheduler.config.k8s.io/v1",
expectedKubeSchedulerLivenessEndpoint: "/healthz",
expectedKubeSchedulerReadinessEndpoint: "/healthz",
expectedKubeSchedulerStartupEndpoint: "/healthz",
Expand All @@ -75,10 +72,10 @@ func TestFeatures(t *testing.T) {
expectedFeatureFlagSeccompDefaultEnabledByDefault: true,
expectedKubeAPIServerSupportsAuthorizationConfigFile: true,
expectedFeatureFlagStructuredAuthorizationConfigurationEnabledByDefault: false,
expectedKubeSchedulerConfigurationAPIVersion: "kubescheduler.config.k8s.io/v1",
expectedKubeSchedulerLivenessEndpoint: "/healthz",
expectedKubeSchedulerReadinessEndpoint: "/healthz",
expectedKubeSchedulerStartupEndpoint: "/healthz",
expectedKubeAPIServerAuthorizationConfigAPIVersion: "apiserver.config.k8s.io/v1alpha1",
},
{
versions: []compatibility.Version{
Expand All @@ -88,10 +85,10 @@ func TestFeatures(t *testing.T) {
expectedFeatureFlagSeccompDefaultEnabledByDefault: true,
expectedKubeAPIServerSupportsAuthorizationConfigFile: true,
expectedFeatureFlagStructuredAuthorizationConfigurationEnabledByDefault: true,
expectedKubeSchedulerConfigurationAPIVersion: "kubescheduler.config.k8s.io/v1",
expectedKubeSchedulerLivenessEndpoint: "/healthz",
expectedKubeSchedulerReadinessEndpoint: "/healthz",
expectedKubeSchedulerStartupEndpoint: "/healthz",
expectedKubeAPIServerAuthorizationConfigAPIVersion: "apiserver.config.k8s.io/v1beta1",
},
{
versions: []compatibility.Version{
Expand All @@ -102,10 +99,10 @@ func TestFeatures(t *testing.T) {
expectedFeatureFlagSeccompDefaultEnabledByDefault: true,
expectedKubeAPIServerSupportsAuthorizationConfigFile: true,
expectedFeatureFlagStructuredAuthorizationConfigurationEnabledByDefault: true,
expectedKubeSchedulerConfigurationAPIVersion: "kubescheduler.config.k8s.io/v1",
expectedKubeSchedulerLivenessEndpoint: "/livez",
expectedKubeSchedulerReadinessEndpoint: "/readyz",
expectedKubeSchedulerStartupEndpoint: "/livez",
expectedKubeAPIServerAuthorizationConfigAPIVersion: "apiserver.config.k8s.io/v1beta1",
},
} {
for _, version := range test.versions {
Expand All @@ -114,7 +111,6 @@ func TestFeatures(t *testing.T) {
assert.Equal(t, test.expectedFeatureFlagSeccompDefaultEnabledByDefault, version.FeatureFlagSeccompDefaultEnabledByDefault())
assert.Equal(t, test.expectedKubeAPIServerSupportsAuthorizationConfigFile, version.KubeAPIServerSupportsAuthorizationConfigFile())
assert.Equal(t, test.expectedFeatureFlagStructuredAuthorizationConfigurationEnabledByDefault, version.FeatureFlagStructuredAuthorizationConfigurationEnabledByDefault())
assert.Equal(t, test.expectedKubeSchedulerConfigurationAPIVersion, version.KubeSchedulerConfigurationAPIVersion())
assert.Equal(t, test.expectedKubeSchedulerLivenessEndpoint, version.KubeSchedulerHealthLivenessEndpoint())
assert.Equal(t, test.expectedKubeSchedulerReadinessEndpoint, version.KubeSchedulerHealthReadinessEndpoint())
})
Expand Down