Does redis or redis-cluster support Istio?
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?
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,
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
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,
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.confYou 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.confCould 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.
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,
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.
- 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.
- 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.
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?
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
Hi,
If you remove the PeerAuthentication object, does it work even if it has the istio sidecar?
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.
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 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-redisandtcp-redis-sentinelregarding this PR: https://github.com/bitnami/charts/pull/2286/filesDo 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
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!
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 .
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.
Hi @drmy did you have a chance to work on this?
@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
Thank you for the information!
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.
Thank you! Please update the ticket with you findings