-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add support for annotations on Deployment/StatefulSet resources in DruidNodeSpec #145
Add support for annotations on Deployment/StatefulSet resources in DruidNodeSpec #145
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add this field in druidSpec ?
You can merge the annotations if specified in both the spec druid nodeSpec and druidSpec. The latter is cluster scoped. Its common to all druid nodes.
Done ✅ Any strong preference on how these are merged? In my opinion it makes sense for the finer-grained DruidNodeSpec-level annotations to override the DruidSpec-level annotations (see implementation), but I see that we do the opposite with PodLabels. |
f5e647e
to
ee37b18
Compare
@SamWheating does Reddit use the operator? if so, can we add you as users in the ADOPTERS.md ? |
Not in any official capacity, this work was completed on my own time and mostly just out of personal interest. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @SamWheating just fix the function name and I'll approve
controllers/druid/handler.go
Outdated
@@ -1287,6 +1289,22 @@ func makeLabelsForNodeSpec(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid, | |||
return labels | |||
} | |||
|
|||
// makeAnnotationsForReplicationController returns the annotations for a Deployment or StatefulSet | |||
// If a given key is set in both the DruidSpec and DruidNodeSpec, the node-scoped value will take precedence. | |||
func makeAnnotationsForReplicationController(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) map[string]string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func makeAnnotationsForReplicationController(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) map[string]string { | |
func makeAnnotationsForWorkload(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) map[string]string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah whoops, I totally missed this 🤦 thanks for spotting!
controllers/druid/handler.go
Outdated
@@ -1287,6 +1289,22 @@ func makeLabelsForNodeSpec(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid, | |||
return labels | |||
} | |||
|
|||
// makeAnnotationsForReplicationController returns the annotations for a Deployment or StatefulSet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``
// makeAnnotationsForReplicationController returns the annotations for a Deployment or StatefulSet | |
// makeAnnotationsForWorkload returns the annotations for a Deployment or StatefulSet |
controllers/druid/handler.go
Outdated
Namespace: m.Namespace, | ||
Labels: ls, | ||
Name: fmt.Sprintf("%s", nodeSpecUniqueStr), | ||
Annotations: makeAnnotationsForReplicationController(nodeSpec, m), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotations: makeAnnotationsForReplicationController(nodeSpec, m), | |
Annotations: makeAnnotationsForWorkload(nodeSpec, m), |
controllers/druid/handler.go
Outdated
Namespace: m.Namespace, | ||
Labels: ls, | ||
Name: fmt.Sprintf("%s", nodeSpecUniqueStr), | ||
Annotations: makeAnnotationsForReplicationController(nodeSpec, m), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotations: makeAnnotationsForReplicationController(nodeSpec, m), | |
Annotations: makeAnnotationsForWorkload(nodeSpec, m), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…uidNodeSpec (datainfrahq#145) * Add support for annotations on Deployment/StatefulSet resources * Support setting ReplicationControllerAnnotations at the cluster-level * rename replicationControllerAnnotations to workloadAnnotations * suggestions from code review
* Ingestion Controller (#53) * ingestion spec acc to v3 * task creation * supprt native batch * fix router url * revert license change * revert go mod change * fix main * fix: made some changes as per review comments * fix: removed unused package from ingestion reconciler * rebase 1 * add example * add review * update dockerfile --------- Co-authored-by: avtarOPS <[email protected]> * Update Docs and Tutorials (#138) * docs and tutorials * Refactor/ordering (#123) * (ordering): refactor code * (ordering): refactor code * (ordering): testing * chore(branch): rebase branch with master * fix(tests): validate nodes order by regex * Bump controller-tools version (#140) * Utilize the DruidIngestion controller in e2e tests (#146) * adds needed volumes to eks deployment spec and improves getting started documentation by noting minio dependency (#149) * Add support for annotations on Deployment/StatefulSet resources in DruidNodeSpec (#145) * Add support for annotations on Deployment/StatefulSet resources * Support setting ReplicationControllerAnnotations at the cluster-level * rename replicationControllerAnnotations to workloadAnnotations * suggestions from code review * Add support for multi tier nodes with different PVC sizes (#106) (#152) Co-authored-by: Farhad Farahi <[email protected]> * fix: put Druid crds in the appropriate folder specified by Helm (#162) Signed-off-by: ahmed.g <[email protected]> Signed-off-by: TessaIO <[email protected]> * Adds service account name to each druid node optionally (#164) * Adds service account to each druid node optionally * Use controller-gen v0.11.2 --------- Signed-off-by: ahmed.g <[email protected]> Signed-off-by: TessaIO <[email protected]> Co-authored-by: AdheipSingh <[email protected]> Co-authored-by: avtarOPS <[email protected]> Co-authored-by: Itamar Marom <[email protected]> Co-authored-by: Jesper Larsson <[email protected]> Co-authored-by: Sam Wheating <[email protected]> Co-authored-by: Evan Jones <[email protected]> Co-authored-by: Farhad Farahi <[email protected]> Co-authored-by: Farhad Farahi <[email protected]> Co-authored-by: Sadananda Aithal <[email protected]>
Fixes #142
Description
Adding a
ReplicationControllerAnnotations
field to the DruidNodeSpec schema. This allows users to specify annotations to be applied to the StatefulSet / Deployment object.I'm not 100% sure of the naming - what do you think? I didn't want to call it
StatefulSetAnnotations
since the user can opt for a deployment instead.Also regenerated the API docs, which led to a huge diff as it appears they weren't regenerated after #53 (hence the huge diff)
This PR has:
I haven't tested this on a real kube cluster, but all of the e2e tests run. Is that sufficient for an overall minor/straightforward change?