Browse Source

add nodeselector and tolerations

master
Vladimir Smagin 1 year ago
parent
commit
a25ed2fa19
Signed by: 21h GPG Key ID: 13BCE12E5618F071
4 changed files with 74 additions and 7 deletions
  1. +11
    -6
      pkg/apis/blindage/v1alpha1/redis_types.go
  2. +44
    -0
      pkg/apis/blindage/v1alpha1/zz_generated.deepcopy.go
  3. +8
    -0
      pkg/controller/manifests/manifest_deployment.go
  4. +11
    -1
      pkg/controller/manifests/manifest_statefulset.go

+ 11
- 6
pkg/apis/blindage/v1alpha1/redis_types.go View File

@ -25,12 +25,17 @@ type RedisSpec struct {
HAProxyBackendCheckInterval int `json:"haproxyBackendCheckInterval,omitempty"` // default 1 (seconds)
// manage resources for Sentinel and Redis
SentinelPodRequests *v1.ResourceList `json:"sentinelPodRequests,omitempty"`
SentinelPodLimits *v1.ResourceList `json:"sentinelPodLimits,omitempty"`
SentinelAffinity *v1.Affinity `json:"sentinelAffinity,omitempty"`
RedisPodRequests *v1.ResourceList `json:"redisPodRequests,omitempty"`
RedisPodLimits *v1.ResourceList `json:"redisPodLimits,omitempty"`
RedisAffinity *v1.Affinity `json:"redisAffinity,omitempty"`
SentinelPodRequests *v1.ResourceList `json:"sentinelPodRequests,omitempty"`
SentinelPodLimits *v1.ResourceList `json:"sentinelPodLimits,omitempty"`
SentinelAffinity *v1.Affinity `json:"sentinelAffinity,omitempty"`
SentinelNodeSelector *map[string]string `json:"sentinelNodeSelector"`
SentinelTolerations *[]v1.Toleration `json:"sentinelTolerations"`
RedisPodRequests *v1.ResourceList `json:"redisPodRequests,omitempty"`
RedisPodLimits *v1.ResourceList `json:"redisPodLimits,omitempty"`
RedisAffinity *v1.Affinity `json:"redisAffinity,omitempty"`
RedisNodeSelector *map[string]string `json:"redisNodeSelector"`
RedisTolerations *[]v1.Toleration `json:"redisTolerations"`
}
// RedisStatus defines the observed state of Redis


+ 44
- 0
pkg/apis/blindage/v1alpha1/zz_generated.deepcopy.go View File

@ -122,6 +122,28 @@ func (in *RedisSpec) DeepCopyInto(out *RedisSpec) {
*out = new(v1.Affinity)
(*in).DeepCopyInto(*out)
}
if in.SentinelNodeSelector != nil {
in, out := &in.SentinelNodeSelector, &out.SentinelNodeSelector
*out = new(map[string]string)
if **in != nil {
in, out := *in, *out
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
}
if in.SentinelTolerations != nil {
in, out := &in.SentinelTolerations, &out.SentinelTolerations
*out = new([]v1.Toleration)
if **in != nil {
in, out := *in, *out
*out = make([]v1.Toleration, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
if in.RedisPodRequests != nil {
in, out := &in.RedisPodRequests, &out.RedisPodRequests
*out = new(v1.ResourceList)
@ -149,6 +171,28 @@ func (in *RedisSpec) DeepCopyInto(out *RedisSpec) {
*out = new(v1.Affinity)
(*in).DeepCopyInto(*out)
}
if in.RedisNodeSelector != nil {
in, out := &in.RedisNodeSelector, &out.RedisNodeSelector
*out = new(map[string]string)
if **in != nil {
in, out := *in, *out
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
}
if in.RedisTolerations != nil {
in, out := &in.RedisTolerations, &out.RedisTolerations
*out = new([]v1.Toleration)
if **in != nil {
in, out := *in, *out
*out = make([]v1.Toleration, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
return
}


+ 8
- 0
pkg/controller/manifests/manifest_deployment.go View File

@ -168,5 +168,13 @@ func GenerateDeployment(cr *blindagev1alpha1.Redis) v1.Deployment {
},
}
if cr.Spec.SentinelNodeSelector != nil {
deployment.Spec.Template.Spec.NodeSelector = *cr.Spec.SentinelNodeSelector
}
if cr.Spec.SentinelTolerations != nil {
deployment.Spec.Template.Spec.Tolerations = *cr.Spec.SentinelTolerations
}
return deployment
}

+ 11
- 1
pkg/controller/manifests/manifest_statefulset.go View File

@ -146,7 +146,7 @@ func GenerateStatefulSet(cr *blindagev1alpha1.Redis) v1.StatefulSet {
replicas = *cr.Spec.RedisReplicas
}
return v1.StatefulSet{
sts := v1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Name: cr.Name + "-redis",
Namespace: cr.Namespace,
@ -165,4 +165,14 @@ func GenerateStatefulSet(cr *blindagev1alpha1.Redis) v1.StatefulSet {
},
},
}
if cr.Spec.RedisNodeSelector != nil {
sts.Spec.Template.Spec.NodeSelector = *cr.Spec.RedisNodeSelector
}
if cr.Spec.RedisTolerations != nil {
sts.Spec.Template.Spec.Tolerations = *cr.Spec.RedisTolerations
}
return sts
}

Loading…
Cancel
Save