-
Notifications
You must be signed in to change notification settings - Fork 115
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 SessionAffinity and SessionAffinityConfig fields to ServiceOptions #571
base: main
Are you sure you want to change the base?
Add SessionAffinity and SessionAffinityConfig fields to ServiceOptions #571
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.
This is a great start!
So what you have done is make the configuration available in the CRD. So the user can now provide it, however it doesn't actually set the configuration on the underlying Services that are created for the SolrCloud/PrometheusExporter.
So we still need to:
- add the controller logic to set these fields when creating services
- make sure the fields are copied correctly when updating the services
- add tests to ensure the fields are propagated correctly
- Add helm chart options
If you want an example of a PR that does something very similar, you can look here: #350
I'm happy to contribute too, I just don't want to step on your toes! Let me know how I can help 🙂
@@ -164,6 +164,14 @@ type ServiceOptions struct { | |||
// Labels to be added for the Service. | |||
// +optional | |||
Labels map[string]string `json:"labels,omitempty"` | |||
|
|||
// Supports "ClientIP" and "None". Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None | |||
// +optional |
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.
// +optional | |
// +optional | |
// +kubebuilder:default=None | |
// +kubebuilder:validation:Enum=None,ClientIP |
So we can actually put the default, and the enum constraints into the CRD itself using Kubebuilder CRD markers!
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, neat code-gen
api/v1beta1/common_types.go
Outdated
|
||
// sessionAffinityConfig contains the configurations of session affinity. | ||
// +optional | ||
SessionAffinityConfig corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"` |
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.
SessionAffinityConfig corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"` | |
SessionAffinityConfig *corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"` |
Making this field a pointer, makes it easier for us to know whether the user provided one or not!
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.
Makes sense
Thanks for the feedback. I think I addressed updating the AFAICT it looks like I need to also update Also, |
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.
The changes look good so far! Just a few comments.
Now for actually implementing and testing!
There are three places to implement this logic.
In controllers/util/solr_util.go
:GenerateCommonService()
. That is what generates the common service for the solrCloud, so that's where we need to take these options from the SolrCloud and pass it to the Service.
In controllers/util/prometheus_exporter_util.go
:GenerateSolrMetricsService()
. This should be exactly (or almost exactly) the same logic as used above. We just need to support the same thing for the prometheus exporter, since it's a shared option amongst all services.
In controllers/util/common.go
:CopyServiceFields()
. This is where we update the existing service with what our "expected state" of the service is. So we are copying from the from
service to the to
service. You can basically copy and paste those if statements, using new ones for sessionAffinity
and sessionAffinityConfig
.
Then our last step will be testing!
// +optional | ||
SessionAffinityConfig corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"` | ||
// +kubebuilder:default=None |
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.
These (the default and enum lines) were meant to be put up above with sessionAffinity
, not sessionAffinityConfig
.
Also just a thought, but we are giving users the option for the headlessService and podService, but those really don't need sessionAffinity, because they are meant to send requests to a single pod, so affinity doesn't matter. So I'm fine leaving those undocumented and unused. |
Attempts to address: #535