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

K0sControlPlane admission webhook #807

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

makhov
Copy link
Contributor

@makhov makhov commented Nov 12, 2024

A simple admission webhook that declines clusters in single mode and update strategy "Recreate"

@makhov makhov force-pushed the admission-hook branch 2 times, most recently from 2195d6b to db4c512 Compare December 4, 2024 09:32
@makhov makhov force-pushed the admission-hook branch 10 times, most recently from d11ab59 to 325d339 Compare December 17, 2024 12:49
@makhov makhov changed the title Admission webhook K0sControlPlane admission webhook Dec 17, 2024
@makhov makhov marked this pull request as ready for review December 17, 2024 14:01
@makhov makhov requested a review from a team as a code owner December 17, 2024 14:01
Comment on lines +90 to +129
if kcp.Spec.UpdateStrategy == v1beta1.UpdateRecreate {

// If the cluster is running in single mode, we can't use the Recreate strategy
if kcp.Spec.K0sConfigSpec.Args != nil {
for _, arg := range kcp.Spec.K0sConfigSpec.Args {
if arg == "--single" {
return fmt.Errorf("UpdateStrategy Recreate strategy is not allowed when the cluster is running in single mode")
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can we remove this block from machine scale reconciliation?

@apedriza
Copy link
Contributor

I am trying to test the webhook by deploying the development version but it doesn't seem to run, even though I force an error with Recreate+--single arg. Do I need something additional? I think it doesn't run in CI either. At least locally following the usual flow I have not been able to. Maybe I am forgetting something

@apedriza apedriza modified the milestone: 1.4 Jan 7, 2025
@apedriza
Copy link
Contributor

I am trying to test the webhook by deploying the development version but it doesn't seem to run, even though I force an error with Recreate+--single arg. Do I need something additional? I think it doesn't run in CI either. At least locally following the usual flow I have not been able to. Maybe I am forgetting something

@makhov do I need something additional? how about adding an e2e test validating the webhook operation?

@makhov
Copy link
Contributor Author

makhov commented Jan 13, 2025

Yeah, I was thinking about adding e2e test once we have envtest in place, but we haven't proceed with it yet, so I need to make something up.

@apedriza
Copy link
Contributor

Yeah, I was thinking about adding e2e test once we have envtest in place, but we haven't proceed with it yet, so I need to make something up.

once this PR is merged I can add some test for this validation logic

@makhov makhov force-pushed the admission-hook branch 4 times, most recently from 41a3cce to ffdd7d9 Compare February 6, 2025 16:11
Signed-off-by: Alexey Makhov <[email protected]>
Signed-off-by: Alexey Makhov <[email protected]>
Signed-off-by: Alexey Makhov <[email protected]>
Signed-off-by: makhov <[email protected]>
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.

2 participants