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

Auto-adjust the API version of the PodSecurityConfiguration resource based on the cluster k8s version #172

Merged
merged 1 commit into from
Jan 9, 2023

Conversation

jiaqiluo
Copy link
Member

@jiaqiluo jiaqiluo commented Jan 9, 2023

Issue rancher/rancher#39992

Problem:
Different API versions for PodSecurityConfiguration is used in different k8s versions: the API version v1beta1 is used in k8s 1.23 and 1.24; v1 is used in k8s 1.25 and above.
Previously, the mutator used version v1 when mutating RKE1 1.23 and 1.24 clusters, which failed to provision clusters due to the error of API version is unknown.

Fix:
This PR allows the mutator to auto-adjust the API version of the PodSecurityConfiguration resource based on the cluster k8s version.

Tests:
The test is done by running the webhook locally and pointing it to a Rancher setup. The provision of the RKE1 cluster with k8s version 1.23, 1,24, and 1,25 all succeed.

@@ -270,15 +259,3 @@ func (v *Validator) validatePSP(request *admission.Request) (*admissionv1.Admiss

return admission.ResponseAllowed(), nil
}

func getClusterVersion(version string) (semver.Version, error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Note to reviewer:
Code refactor, this function is moved to pkg/podsecurityadmission/podsecurityadmission.go

@jiaqiluo jiaqiluo requested a review from a team January 9, 2023 01:20
HarrisonWAffel
HarrisonWAffel previously approved these changes Jan 9, 2023
@HarrisonWAffel HarrisonWAffel requested a review from a team January 9, 2023 15:17
@jiaqiluo jiaqiluo requested review from KevinJoiner and a team January 9, 2023 17:09
pkg/resources/validation/cluster/cluster.go Outdated Show resolved Hide resolved
pkg/podsecurityadmission/podsecurityadmission.go Outdated Show resolved Hide resolved
pkg/podsecurityadmission/podsecurityadmission.go Outdated Show resolved Hide resolved
pkg/podsecurityadmission/podsecurityadmission.go Outdated Show resolved Hide resolved
pkg/podsecurityadmission/podsecurityadmission.go Outdated Show resolved Hide resolved
pkg/podsecurityadmission/podsecurityadmission.go Outdated Show resolved Hide resolved
pkg/podsecurityadmission/podsecurityadmission.go Outdated Show resolved Hide resolved
pkg/resources/mutation/cluster/cluster.go Show resolved Hide resolved
pkg/resources/validation/cluster/cluster.go Outdated Show resolved Hide resolved
Copy link
Contributor

@KevinJoiner KevinJoiner left a comment

Choose a reason for hiding this comment

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

LGTM

@jiaqiluo jiaqiluo merged commit 0d89674 into rancher:release/v0.3 Jan 9, 2023
@jiaqiluo jiaqiluo deleted the fix-psa-api-version branch January 9, 2023 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants