charts icon indicating copy to clipboard operation
charts copied to clipboard

Does redis or redis-cluster support Istio?

Open drmy opened this issue 5 years ago • 31 comments

Which chart:

bitnami/redis bitnami/redis-cluster

Describe the bug

Hi, I tested to enable Istio for my bitnami/redis (Sentinel mode) and another redis-cluster, both failed on issue of communication between master and slaves.

I searched Internet and got the Istio official post as below: https://istio.io/latest/faq/applications/#redis

I got three other posts more about this topic:

istio-redis-culster deploying-redis-cluster migrating-to-redis-cluster-using-envoy-93a87ae79dc3 Implement REPLACE operation for EnvoyFilter patch

I also saw another post saying we might need to enable hostNetwork for the Redis nodes to share the host network IP and port.

Do we have a document or guide on how to setup the bitnami/redis with Sentinel or redis-cluster to be able to run in Istio?

drmy avatar Dec 13 '20 00:12 drmy

Hi,

Thanks for using Bitnami! Could you let us know which error appeared when enabling Istio? In principle, there shouldn't be any issue when enabling Istio.

javsalgar avatar Dec 14 '20 09:12 javsalgar

Hi,

Thanks for using Bitnami! Could you let us know which error appeared when enabling Istio? In principle, there shouldn't be any issue when enabling Istio.

Hi @javsalgar ,

I am using the redis-cluster (6 nodes) with disabled TLS and it is running in a Istio 1.8.1 environment.

The problem is that when my client app (written by StackExchange.Redis in .Net Core) connects to the Redis cluster, it can connect but is followed by the following log errors, while Redis log is clear.

I am thinking if we have to do some thing mentioned in the pages below manually? istio-redis-culster The Istio 1.8.1 does have included the PR mentioned above. OR: istio applications faq - redis

My client app errors: 2020-12-14 15:31:42.9326|INFO|IConnectionMultiplexer|Redis Client is trying to connect with TLS = False, Available Hosts : Unspecified/redis-cluster:6379 2020-12-14 15:31:43.1558|INFO|IConnectionMultiplexer|Redis successfully connected. 2020-12-14 15:31:43.2643|WARN|IConnectionMultiplexer|Redis error message received. endpoint : Unspecified/redis-cluster:6379, message : CLUSTERDOWN Hash slot not served 2020-12-14 15:31:43.2907|ERROR|Program|Error occurred when starting application|StackExchange.Redis.RedisServerException: CLUSTERDOWN Hash slot not served

drmy avatar Dec 14 '20 15:12 drmy

Hi,

Checking the documentation, I saw this

https://istio.io/latest/faq/applications/#redis

echo "" >> /opt/bitnami/redis/etc/replica.conf
echo "replica-announce-ip $POD_IP" >> /opt/bitnami/redis/etc/replica.conf

You could set this value:

slave:
  extraEnvVars:
  - name: "POD_IP"
    valueFrom:
      fieldRef:
        fieldPath: status.podIP
   preExecCmds:  | 
     echo "" >> /opt/bitnami/redis/etc/replica.conf
     echo "replica-announce-ip $POD_IP" >> /opt/bitnami/redis/etc/replica.conf

Could you check if it works for you?

javsalgar avatar Dec 15 '20 08:12 javsalgar

Hi,

Checking the documentation, I saw this

https://istio.io/latest/faq/applications/#redis

echo "" >> /opt/bitnami/redis/etc/replica.conf
echo "replica-announce-ip $POD_IP" >> /opt/bitnami/redis/etc/replica.conf

You could set this value:

slave:
  extraEnvVars:
  - name: "POD_IP"
    valueFrom:
      fieldRef:
        fieldPath: status.podIP
   preExecCmds:  | 
     echo "" >> /opt/bitnami/redis/etc/replica.conf
     echo "replica-announce-ip $POD_IP" >> /opt/bitnami/redis/etc/replica.conf

Could you check if it works for you?

Hi @javsalgar, Thank you for the help.

As you suggested I set the value in my redis-cluster StatefulSet, it indeed created the env variable POD_IP with correct value. However I see those errors as below:

2020-12-15 13:00:38.1076|WARN|IConnectionMultiplexer|Redis error message received. endpoint : Unspecified/redis-cluster:6379, message : CLUSTERDOWN Hash slot not served

And, I made another test by deploying a bitnami/redis the Sentinel mode. I also added the POD_IP env and I got the following errors from Redis slave nodes. The salves failed to connect to Redis master.

1:S 15 Dec 2020 13:43:09.965 * Connecting to MASTER :0 1:S 15 Dec 2020 13:43:09.965 # Unable to connect to MASTER: Invalid argument 1:S 15 Dec 2020 13:43:10.969 * Connecting to MASTER :0 1:S 15 Dec 2020 13:43:10.969 # Unable to connect to MASTER: Invalid argument 1:S 15 Dec 2020 13:43:11.973 * Connecting to MASTER :0 1:S 15 Dec 2020 13:43:11.973 # Unable to connect to MASTER: Invalid argument 1:S 15 Dec 2020 13:43:12.977 * Connecting to MASTER :0 1:S 15 Dec 2020 13:43:12.977 # Unable to connect to MASTER: Invalid argument

Both issues from the redis Sentinel and redis-cluster only occur when they are running in the Istio service mesh mode.

drmy avatar Dec 15 '20 13:12 drmy

Hi,

I see. So, just to confirm and create enough information for the investigation ticket. With the values I mentioned it works without issues without Istio, right?

javsalgar avatar Dec 16 '20 08:12 javsalgar

Hi,

I see. So, just to confirm and create enough information for the investigation ticket. With the values I mentioned it works without issues without Istio, right?

Hi @javsalgar ,

That is correct. The values you mentioned can work correctly to create the POD_IP env with correct ip address.

My Redis is running in a namespace.

  1. If I enable the Istio auto-injection by set label istio-injection=enabled to the namespace, then the Redis will run with a istio side-car and get this problem -- as I described in last post - redis-cluser and redis sentinel got different errors.
  2. If I remove the istio-injection label from the namespace then my Redis is running well and can accept clients' connection.

Both test cases are with the values of POP_IP.

Thank you very much for helping me to look into this issue, @javsalgar . Really appreciated.

drmy avatar Dec 16 '20 14:12 drmy

Hi,

Could you provide more details about the clients you are using to connect? Could it be that you forced istio mtls and it won't work from clients without it?

javsalgar avatar Dec 17 '20 16:12 javsalgar

Hi,

Could you provide more details about the clients you are using to connect? Could it be that you forced istio mtls and it won't work from clients without it?

My redis is configured to use the following peer authentication with port 6379 on PERMISSIVE mode. And I disabled the Redis tls.authClients. My client is written by the Stackexchange.redis lib.

kind: PeerAuthentication apiVersion: security.istio.io/v1beta1 metadata: name: {{ template "common.names.fullname" . }} spec: selector: matchLabels: app.kubernetes.io/name: {{ template "common.names.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} mtls: mode: STRICT portLevelMtls: '6379': mode: PERMISSIVE '9121': mode: PERMISSIVE

drmy avatar Dec 18 '20 04:12 drmy

Hi,

If you remove the PeerAuthentication object, does it work even if it has the istio sidecar?

javsalgar avatar Dec 18 '20 15:12 javsalgar

Hi,

If you remove the PeerAuthentication object, does it work even if it has the istio sidecar?

Hi @javsalgar , Thanks for asking. I tried to not apply the PeerAuthentication object, it still didn't work.

I am thinking that this may not be an issue of Redis supporting Istio, it could be an issue with Istio for supporting Redis. Because I saw some posts said that Istio doesn't work well with supporting headless-service, StatefulSet on Redis, RabbitMQ, etc. when mTLS is enabled. (I tried to set mTLS=DISABLE and it also failed.)

So far, below is the only article I read, which states that his customized redis-cluster can work with Istio: https://github.com/zhaohuabing/istio-redis-culster

Using the bitnami helm chart of redis sentinel or redis-cluster, I haven't made it work yet. If anyone can confirm this is an issue with Istio or Redis charts, It would be much appreciated. Thank you.

drmy avatar Dec 21 '20 02:12 drmy

Hi I was doing some researches and it seems there could be some missing istio requirements that affect the service port name. Currently, we have it like

  ports:
    - name: redis
      port: {{ .Values.redisPort }}
      targetPort: redis
  {{- if .Values.sentinel.enabled }}
    - name: redis-sentinel
      port: {{ .Values.sentinel.port }}
      targetPort: redis-sentinel
  {{- end }}

But it seems that it should be prefixed by the protocol like http-redis and tcp-redis-sentinel regarding this PR: https://github.com/bitnami/charts/pull/2286/files

Do you think it could work?

dani8art avatar Dec 22 '20 11:12 dani8art

Hi I was doing some researches and it seems there could be some missing istio requirements that affect the service port name. Currently, we have it like

  ports:
    - name: redis
      port: {{ .Values.redisPort }}
      targetPort: redis
  {{- if .Values.sentinel.enabled }}
    - name: redis-sentinel
      port: {{ .Values.sentinel.port }}
      targetPort: redis-sentinel
  {{- end }}

But it seems that it should be prefixed by the protocol like http-redis and tcp-redis-sentinel regarding this PR: https://github.com/bitnami/charts/pull/2286/files

Do you think it could work?

Hi @dani8art ,

Thank you for the info. I havn't got a chance to test with the PR changes but I remembered that I ever made a similar try of code changes to the charts before -- rename the port name from "redis" to "tcp-redis" -- I wished Istio to select TCP protol for redis rather than the "redis protocol" that is supposed to be used only in the redis-cluster mode? I am not sure but my that test was still failed. Looking at the following Istio page, the official states that the "redis" protocol is disabled by default, and if the port name doesn't match those explicit supported protocols by Istio then TCP protocol will be selected by default, therefore I am not sure if changing the port name in the Redis chart would actually make any difference for my issue.

https://istio.io/latest/docs/ops/configuration/traffic-management/protocol-selection/#automatic-protocol-selection

drmy avatar Dec 23 '20 14:12 drmy

Could you try to give a try to these changes, please? if no, we can evaluate the differences between our chart and the manifest you shared.

So far, below is the only article I read, which states that his customized redis-cluster can work with Istio: https://github.com/zhaohuabing/istio-redis-culster

Thanks!

dani8art avatar Dec 24 '20 10:12 dani8art

Could you try to give a try to these changes, please? if no, we can evaluate the differences between our chart and the manifest you shared.

So far, below is the only article I read, which states that his customized redis-cluster can work with Istio: https://github.com/zhaohuabing/istio-redis-culster

Thanks!

Absolutely, that is what I am going to try. I will let you know my test result. Thank you @dani8art .

drmy avatar Dec 24 '20 11:12 drmy

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

stale[bot] avatar Jan 10 '21 14:01 stale[bot]

Hi @drmy did you have a chance to work on this?

dani8art avatar Jan 11 '21 08:01 dani8art

@dani8art I ran into a very similar issue requiring much of what was discussed here. I have outlined what I needed to do here: https://github.com/bitnami/charts/issues/5016

MichaelHudgins avatar Jan 13 '21 18:01 MichaelHudgins

Thank you for the information!

javsalgar avatar Jan 14 '21 08:01 javsalgar

Hi @drmy did you have a chance to work on this?

Hi @dani8art , I applogize for the late since busying in my work recently. I was trying to test that solution however I didn't succeed yet by following those instructions. I many need more time to research on that, will keep you updated once I get something new.

drmy avatar Jan 16 '21 06:01 drmy

Thank you! Please update the ticket with you findings

javsalgar avatar Jan 18 '21 09:01 javsalgar