Browse Source

separate resources limits

tags/0.0.2
Vladimir Smagin 1 month ago
parent
commit
361192c58d
Signed by: Vladimir Smagin <21h@blindage.org> GPG Key ID: 13BCE12E5618F071

+ 1
- 1
VERSION View File

@@ -1 +1 @@
0.0.1
0.0.2

+ 2
- 0
go.mod View File

@@ -35,3 +35,5 @@ replace (
sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.1.12
sigs.k8s.io/controller-tools => sigs.k8s.io/controller-tools v0.1.11-0.20190411181648-9d55346c2bde
)

go 1.13

+ 7
- 4
pkg/apis/blindage/v1alpha1/redis_types.go View File

@@ -24,10 +24,13 @@ type RedisSpec struct {
HAProxyTimeoutClient int `json:"haproxyTimeoutClient,omitempty"` // default 30 (seconds)
HAProxyBackendCheckInterval int `json:"haproxyBackendCheckInterval,omitempty"` // default 1 (seconds)

// manage resources
PodRequests *v1.ResourceList `json:"podRequests,omitempty"`
PodLimits *v1.ResourceList `json:"podLimits,omitempty"`
Affinity *v1.Affinity `json:"affinity,omitempty"`
// 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"`
}

// RedisStatus defines the observed state of Redis

+ 33
- 6
pkg/apis/blindage/v1alpha1/zz_generated.deepcopy.go View File

@@ -95,8 +95,8 @@ func (in *RedisSpec) DeepCopyInto(out *RedisSpec) {
*out = new(int32)
**out = **in
}
if in.PodRequests != nil {
in, out := &in.PodRequests, &out.PodRequests
if in.SentinelPodRequests != nil {
in, out := &in.SentinelPodRequests, &out.SentinelPodRequests
*out = new(v1.ResourceList)
if **in != nil {
in, out := *in, *out
@@ -106,8 +106,8 @@ func (in *RedisSpec) DeepCopyInto(out *RedisSpec) {
}
}
}
if in.PodLimits != nil {
in, out := &in.PodLimits, &out.PodLimits
if in.SentinelPodLimits != nil {
in, out := &in.SentinelPodLimits, &out.SentinelPodLimits
*out = new(v1.ResourceList)
if **in != nil {
in, out := *in, *out
@@ -117,8 +117,35 @@ func (in *RedisSpec) DeepCopyInto(out *RedisSpec) {
}
}
}
if in.Affinity != nil {
in, out := &in.Affinity, &out.Affinity
if in.SentinelAffinity != nil {
in, out := &in.SentinelAffinity, &out.SentinelAffinity
*out = new(v1.Affinity)
(*in).DeepCopyInto(*out)
}
if in.RedisPodRequests != nil {
in, out := &in.RedisPodRequests, &out.RedisPodRequests
*out = new(v1.ResourceList)
if **in != nil {
in, out := *in, *out
*out = make(map[v1.ResourceName]resource.Quantity, len(*in))
for key, val := range *in {
(*out)[key] = val.DeepCopy()
}
}
}
if in.RedisPodLimits != nil {
in, out := &in.RedisPodLimits, &out.RedisPodLimits
*out = new(v1.ResourceList)
if **in != nil {
in, out := *in, *out
*out = make(map[v1.ResourceName]resource.Quantity, len(*in))
for key, val := range *in {
(*out)[key] = val.DeepCopy()
}
}
}
if in.RedisAffinity != nil {
in, out := &in.RedisAffinity, &out.RedisAffinity
*out = new(v1.Affinity)
(*in).DeepCopyInto(*out)
}

+ 6
- 6
pkg/controller/manifests/manifest_deployment.go View File

@@ -12,18 +12,18 @@ func GenerateDeployment(cr *blindagev1alpha1.Redis) v1.Deployment {

// check affinity rules
affinity := &corev1.Affinity{}
if cr.Spec.Affinity != nil {
affinity = cr.Spec.Affinity
if cr.Spec.SentinelAffinity != nil {
affinity = cr.Spec.SentinelAffinity
}

resourcesLimits := corev1.ResourceList{}
if cr.Spec.PodLimits != nil {
resourcesLimits = *cr.Spec.PodLimits
if cr.Spec.SentinelPodLimits != nil {
resourcesLimits = *cr.Spec.SentinelPodLimits
}

resourcesRequests := corev1.ResourceList{}
if cr.Spec.PodRequests != nil {
resourcesRequests = *cr.Spec.PodRequests
if cr.Spec.SentinelPodRequests != nil {
resourcesRequests = *cr.Spec.SentinelPodRequests
}

ports := []corev1.ContainerPort{

+ 6
- 6
pkg/controller/manifests/manifest_statefulset.go View File

@@ -15,18 +15,18 @@ func GenerateStatefulSet(cr *blindagev1alpha1.Redis) v1.StatefulSet {

// check affinity rules
affinity := &corev1.Affinity{}
if cr.Spec.Affinity != nil {
affinity = cr.Spec.Affinity
if cr.Spec.RedisAffinity != nil {
affinity = cr.Spec.RedisAffinity
}

resourcesLimits := corev1.ResourceList{}
if cr.Spec.PodLimits != nil {
resourcesLimits = *cr.Spec.PodLimits
if cr.Spec.RedisPodLimits != nil {
resourcesLimits = *cr.Spec.RedisPodLimits
}

resourcesRequests := corev1.ResourceList{}
if cr.Spec.PodRequests != nil {
resourcesRequests = *cr.Spec.PodRequests
if cr.Spec.RedisPodRequests != nil {
resourcesRequests = *cr.Spec.RedisPodRequests
}

image := "redis:latest"

+ 1
- 1
version/version.go View File

@@ -1,5 +1,5 @@
package version

var (
Version = "0.0.1"
Version = "0.0.2"
)

Loading…
Cancel
Save