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

Move defaulting from webhooks to CRD #51

Closed
kvaps opened this issue Mar 20, 2024 · 3 comments · Fixed by #57
Closed

Move defaulting from webhooks to CRD #51

kvaps opened this issue Mar 20, 2024 · 3 comments · Fixed by #57
Milestone

Comments

@kvaps
Copy link
Member

kvaps commented Mar 20, 2024

Consider replacing defaulting webhook with native CRD validation:

if r.Spec.Replicas == 0 {
r.Spec.Replicas = 3
}

// +kubebuilder:default:=3

@kvaps
Copy link
Member Author

kvaps commented Mar 20, 2024

Also shouldn't we use pointers for those values to explicitly specify value if it wasn't specified?

Otherwise it might be blocking to scale etcd cluster to 0 replicas.

@kvaps kvaps added this to the v0.0.1 milestone Mar 20, 2024
@kvaps kvaps changed the title Move defaulting and validation from webhooks to CRD Move defaulting from webhooks to CRD Mar 20, 2024
@sircthulhu
Copy link
Member

After tests I found out annotation // +kubebuilder:default:=3 only adds data to CRD, it does not protect us from creating CR EtcdCluster with zero replicas

@kvaps
Copy link
Member Author

kvaps commented Mar 20, 2024

It's okay, I think we're should have an opportunity to start with 0

sircthulhu added a commit that referenced this issue Mar 21, 2024
- `Replicas` field type changed to *int32 according to k8s api
guidelines
- remove unnecessary validation (everything is validated using OpenAPI
scheme)
- allow creation of cluster with 0 replicas

fixes #51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants