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

operator v1: API only: add NodePools to Cluster CRD #221

Merged
merged 4 commits into from
Sep 11, 2024

Conversation

birdayz
Copy link
Contributor

@birdayz birdayz commented Sep 9, 2024

This introduces NodePools to the Cluster CRD.

NodePools allow configuration of independent pod-sets, that are often backed by specific CloudProvider NodePools. This allows for safe blue/green deployments end-to-end; from cloud provider NodePool to the Pods in the Kubernetes Cluster.

Despite this being discussed, this change does not add a PodTemplateSpec to NodePoolSpec. It sounds overly generic, and it is not used in the existing code either. Our goal here is to stay as close as possible to existing practices (and we have no concrete use for PodTemplateSpec at the moment anyway). In addition, we want to re-use the existing RedpandaResourceRequirements type, just as it used before this patch.

There will probably later follow an additional CloudStorage/CacheStorage related field, however there's an unsolved problem at the moment, that will not make it very useful yet. It will be added separately.

The actual implementation will follow in a later PR. Having the API spec merged ahead of the implementation will make it much easier for cloud to ship a feature flag that makes use of the new implementation.

This introduces NodePools to the Cluster CRD.

NodePools allow configuration of independent pod-sets, that are often
backed by specific NodePools. This allows for safe blue/green
deployments end-to-end; from cloud provider NodePool to the Pods in the
Kubernetes Cluster.

Despite this being discussed, this change does not add a PodTemplateSpec
to NodePoolSpec. It sounds overly generic, and it is not used in the
existing code either. Our goal here is to stay as close as possible to
existing practices (and we have no concrete use for PodTemplateSpec at
the moment anyway). In addition, we want to re-use the existing
RedpandaResourceRequirements type, just as it used before this patch.
@birdayz birdayz changed the title operator v1: add NodePools to Cluster CRD operator v1: API only: add NodePools to Cluster CRD Sep 9, 2024
@@ -116,7 +116,7 @@ type ClusterSpec struct {
// containers have separate resources settings and the amount of resources
// assigned to these containers will be required on the cluster on top of
// the resources defined here
Resources RedpandaResourceRequirements `json:"resources"`
Resources RedpandaResourceRequirements `json:"resources,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this needs to receive omitempty, because we need to make it optional AFAIK. so we can have a CR without it (w/o a default nodepool basically, only ones listed in spec.nodePools)

Copy link
Contributor

Choose a reason for hiding this comment

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

If you leave that as is you will have Resources of type RedpandaResourceRequirements which if not provided it will default to 0. To differentiate not provided value and zero value I'm used to making it a pointer to a struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this an allowed, compatible change? making it pointer? i am not sure about the wire format implications; i guess only that null/absence is also possible

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is compatible change as any user that used or did not use resources would not see any difference.

Never the less Cluster custom resource is not defined in our product. Only cloud is using it and K8S team maintains only Redpanda CRD.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i updated it to pointer.

please do not merge yet, i will merge once i've tested this on our end regarding compatibility. pretty sure you are right, it's fine, but want to test just in case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed back to what it was, non pointer.

all the code already treats this struct as de facto optional, eg:

requestedCores := requests.RedpandaCPU().Value()
// When cpu is not set, all cores are used
	if requestedCores > 0 {
		args["smp"] = strconv.FormatInt(requestedCores, 10)
	}

it is already possible to not provide this field. No need to change it to pointer. Changing to pointer requires a lot of changes along the way, because it's then nil-able.

Copy link
Contributor

@RafalKorepta RafalKorepta left a comment

Choose a reason for hiding this comment

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

From my side it looks good. Maybe @andrewstucki or @chrisseto could double check.

// Replicas, so they can be controlled independently
// Resources, because this is tied strongly to the actual machine shape backing the NodePool.
type NodePoolSpec struct {
Name string `json:"name"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we discussed this but I don't recall the outcome, did you consider placing a PodTemplate here instead of only allowing Tolerations and NodeSelector to be overridden?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i added a comment here already:

Despite this being discussed, this change does not add a PodTemplateSpec to NodePoolSpec. It sounds overly generic, and it is not used in the existing code either. Our goal here is to stay as close as possible to existing practices (and we have no concrete use for PodTemplateSpec at the moment anyway). In addition, we want to re-use the existing RedpandaResourceRequirements type, just as it used before this patch.

i would prefer staying as close as possible to the existing CRD and code, and not introduce new "nice" things. unless there's an actual use case for it.

so, saving such more structural changes for a "operator v3" or "cloud operator CRD"

src/go/k8s/api/vectorized/v1alpha1/cluster_types.go Outdated Show resolved Hide resolved
// Replicas, so they can be controlled independently
// Resources, because this is tied strongly to the actual machine shape backing the NodePool.
type NodePoolSpec struct {
Name string `json:"name"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe worth including a validation on minimum length here so we don't forget to specify this given that an empty string would be valid? Or is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added min len 3

@birdayz
Copy link
Contributor Author

birdayz commented Sep 10, 2024

thanks for the feedback. i will address the comments and do another cleanup tomorrow.

@birdayz birdayz force-pushed the jb/nodepools-api-changes-only branch 2 times, most recently from 98ae0bc to 58151c2 Compare September 11, 2024 10:34
@birdayz birdayz force-pushed the jb/nodepools-api-changes-only branch from 58151c2 to 688cf6b Compare September 11, 2024 11:00
@birdayz birdayz merged commit 5cc16a8 into main Sep 11, 2024
5 checks passed
@RafalKorepta RafalKorepta deleted the jb/nodepools-api-changes-only branch December 2, 2024 13:26
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