Browse Source

move backend check interval to crd

tags/0.0.2
Vladimir Smagin 1 year ago
parent
commit
13f57754bd
Signed by: 21h GPG Key ID: 13BCE12E5618F071
2 changed files with 13 additions and 7 deletions
  1. +6
    -5
      pkg/apis/blindage/v1alpha1/redis_types.go
  2. +7
    -2
      pkg/controller/redis/redis_controller.go

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

@@ -20,11 +20,12 @@ type RedisSpec struct {
PersistentVolumeSize resource.Quantity `json:"persistentVolumeSize,omitempty"` // default 1Gi

// haproxy
UseHAProxy bool `json:"useHAProxy,omitempty"` // set true to activate HAProxy deployment
HAProxyImage string `json:"haproxyImage,omitempty"` // override default haproxy:1.9.4-alpine
HAProxyReplicas *int32 `json:"haproxyReplicas,omitempty"` // override default 1
HAProxyTimeoutServer int `json:"haproxyTimeoutServer,omitempty"` // default 30
HAProxyTimeoutClient int `json:"haproxyTimeoutClient,omitempty"` // default 30
UseHAProxy bool `json:"useHAProxy,omitempty"` // set true to activate HAProxy deployment
HAProxyImage string `json:"haproxyImage,omitempty"` // override default haproxy:1.9.4-alpine
HAProxyReplicas *int32 `json:"haproxyReplicas,omitempty"` // override default 1
HAProxyTimeoutServer int `json:"haproxyTimeoutServer,omitempty"` // default 30 (seconds)
HAProxyTimeoutClient int `json:"haproxyTimeoutClient,omitempty"` // default 30 (seconds)
HAProxyBackendCheckInterval int `json:"haproxyBackendCheckInterval,omitempty"` // default 1 (seconds)

// manage resources
PodRequests *v1.ResourceList `json:"podRequests,omitempty"`


+ 7
- 2
pkg/controller/redis/redis_controller.go View File

@@ -266,11 +266,16 @@ done
return reconcile.Result{}, err
}

redisEndpointTemplate := " server redis_backend_%v %v:6379 maxconn 1024 check inter 1s\n"
redisEndpointTemplate := " server redis_backend_%v %v:6379 maxconn 1024 check inter %vs\n"
redisEndpoints := ""

haproxyBackendCheckInterval := 1
if instance.Spec.HAProxyBackendCheckInterval > 0 {
haproxyBackendCheckInterval = instance.Spec.HAProxyBackendCheckInterval
}

for num, ip := range podIPs {
redisEndpoints = redisEndpoints + fmt.Sprintf(redisEndpointTemplate, num, ip)
redisEndpoints = redisEndpoints + fmt.Sprintf(redisEndpointTemplate, num, ip, haproxyBackendCheckInterval)
}

configHaproxyConfigName := instance.Name + "-haproxy"


Loading…
Cancel
Save