feat(redis): add affinity configuration

Signed-off-by: kastakhov <16296930+kastakhov@users.noreply.github.com>
Assisted-by: LLM
This commit is contained in:
kastakhov committed 2026-11-16 13:16:29 +00:00
1 parent 416abfd8e2
commit 977963dda2
8 files changed
+163 -14

No files matched your search

+13
View File
@@ -7,6 +7,7 @@ package redis
import (
resource "k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/apis/meta/v1"
k8sRuntime "k8s.io/apimachinery/pkg/runtime"
)
// +kubebuilder:object:root=true
@@ -26,6 +27,9 @@ type ConfigSpec struct {
// Default sizing preset used when `resources` is omitted.
// +kubebuilder:default:="t1.nano"
ResourcesPreset ResourcesPreset `json:"resourcesPreset"`
// Kubernetes affinity configuration for Redis and Sentinel pods.
// +kubebuilder:default:={}
Affinity AffinitySpec `json:"affinity,omitempty"`
// Persistent Volume Claim size available for application data.
// +kubebuilder:default:="1Gi"
Size resource.Quantity `json:"size"`
@@ -64,6 +68,15 @@ type ConfigSpec struct {
Sentinel Sentinel `json:"sentinel,omitempty"`
}
type AffinitySpec struct {
// Kubernetes Affinity for Redis pods. When set, redis-operator uses it verbatim and does not add its default soft podAntiAffinity; include podAntiAffinity unless replica co-location is intended.
// +kubebuilder:default:={}
Redis *k8sRuntime.RawExtension `json:"redis,omitempty"`
// Kubernetes Affinity for Sentinel pods. When set, redis-operator uses it verbatim and does not add its default soft podAntiAffinity; include podAntiAffinity unless replica co-location is intended.
// +kubebuilder:default:={}
Sentinel *k8sRuntime.RawExtension `json:"sentinel,omitempty"`
}
type Resources struct {
// CPU available to each replica.
Cpu resource.Quantity `json:"cpu,omitempty"`
+27 -1
View File
@@ -21,9 +21,34 @@ limitations under the License.
package redis
import (
runtime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AffinitySpec) DeepCopyInto(out *AffinitySpec) {
*out = *in
if in.Redis != nil {
in, out := &in.Redis, &out.Redis
*out = new(runtime.RawExtension)
(*in).DeepCopyInto(*out)
}
if in.Sentinel != nil {
in, out := &in.Sentinel, &out.Sentinel
*out = new(runtime.RawExtension)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AffinitySpec.
func (in *AffinitySpec) DeepCopy() *AffinitySpec {
if in == nil {
return nil
}
out := new(AffinitySpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Config) DeepCopyInto(out *Config) {
*out = *in
@@ -54,6 +79,7 @@ func (in *Config) DeepCopyObject() runtime.Object {
func (in *ConfigSpec) DeepCopyInto(out *ConfigSpec) {
*out = *in
in.Resources.DeepCopyInto(&out.Resources)
in.Affinity.DeepCopyInto(&out.Affinity)
out.Size = in.Size.DeepCopy()
in.Tls.DeepCopyInto(&out.Tls)
if in.MinReplicasToWrite != nil {