From 3a528a2b3285a49790b2f370bc1b699554875d43 Mon Sep 17 00:00:00 2001 From: "egor.lyutov" Date: Wed, 8 Dec 2021 16:08:40 +0500 Subject: [PATCH] added support for redis auth Signed-off-by: egor.lyutov --- api/v1alpha1/ratelimitservice_types.go | 1 + .../bases/ratelimit.zufardhiyaulhaq.com_ratelimitservices.yaml | 2 ++ examples/global/README.md | 1 + pkg/service/configmap_env_builder.go | 1 + 4 files changed, 5 insertions(+) diff --git a/api/v1alpha1/ratelimitservice_types.go b/api/v1alpha1/ratelimitservice_types.go index df54efe..3f064b9 100644 --- a/api/v1alpha1/ratelimitservice_types.go +++ b/api/v1alpha1/ratelimitservice_types.go @@ -45,6 +45,7 @@ type RateLimitServiceSpec_Backend struct { type RateLimitService_RedisBackend struct { Type string `json:"type,omitempty"` URL string `json:"url,omitempty"` + Auth string `json:"auth,omitempty"` } type RateLimitServiceStatus struct { diff --git a/config/crd/bases/ratelimit.zufardhiyaulhaq.com_ratelimitservices.yaml b/config/crd/bases/ratelimit.zufardhiyaulhaq.com_ratelimitservices.yaml index 4ca4da0..0354115 100644 --- a/config/crd/bases/ratelimit.zufardhiyaulhaq.com_ratelimitservices.yaml +++ b/config/crd/bases/ratelimit.zufardhiyaulhaq.com_ratelimitservices.yaml @@ -40,6 +40,8 @@ spec: properties: redis: properties: + auth: + type: string type: type: string url: diff --git a/examples/global/README.md b/examples/global/README.md index 6e27e18..da5a5f2 100644 --- a/examples/global/README.md +++ b/examples/global/README.md @@ -51,6 +51,7 @@ spec: redis: type: "single" url: "172.30.0.13:6379" + auth: "password" ``` It's support single, sentinel, or clustered Redis. `spec.backend.redis.url` is very depends on `spec.backend.redis.type`. You can check official [Envoy ratelimit service](https://github.com/envoyproxy/ratelimit#redis-type) service for Sentinel and Clustered Redis. diff --git a/pkg/service/configmap_env_builder.go b/pkg/service/configmap_env_builder.go index 39c187d..a3cf8a5 100644 --- a/pkg/service/configmap_env_builder.go +++ b/pkg/service/configmap_env_builder.go @@ -58,6 +58,7 @@ func (n *EnvBuilder) buildRedisEnv() (map[string]string, error) { data["USE_STATSD"] = "false" data["REDIS_TYPE"] = n.RateLimitService.Spec.Backend.Redis.Type data["REDIS_URL"] = n.RateLimitService.Spec.Backend.Redis.URL + data["REDIS_AUTH"] = n.RateLimitService.Spec.Backend.Redis.Auth return data, nil }