microservices-demo
microservices-demo copied to clipboard
Missing Database in Multi-cluster with Istio
Original title of this issue: Cart services in multi cluster istio mode does not keep cart details while refresh browser
Cart services deployed in two Kubernetes cluster with isio has issues as there is no database , session switch between clusters and cart is empty and next refresh cart shows the correct number. Might need something with common database . Is there any fix for it.
What about leveraging an external service for the redis database? Like for example the Memorystore (redis) service? https://github.com/GoogleCloudPlatform/microservices-demo/blob/master/docs/memorystore.md
Thanks for your response but I am testing this on-prem which is outside GCP.
Hello, if you're using Istio on-prem, could you set up multicluster service discovery and just have one instance of Redis in one cluster? And route the other cluster's cartservice to it? https://istio.io/latest/docs/setup/install/multicluster/multi-primary/#enable-endpoint-discovery
Or are you already doing this and it's causing that refresh bug?
I just tested this scenario where the in-cluster redis db is in cluster 1 only and not in cluster 2. And I got the issue described here, JFYI.
Actually even with the cleaner and new implementation coming soon (#838) of the cartservice interacting with the redis database, the issue is still here, I just re-tested with the old and new version of cartservice.
And actually, that's not an issue, that's a feature :)
This behavior is due to the implementaton of the SessionId/UserId in the frontend app as a Cookie (shop_session-id) per instance, see here: https://github.com/GoogleCloudPlatform/microservices-demo/blob/65b552273a26714f730253a89321ac8f381882fc/src/frontend/middleware.go#L84
Maybe a way to allow a common redis database across clusters and actually a common SessionId/UserId could be to have an environment variable for either the frontend app or the cartservie app. This environment variable could be for example named UNIQUE_USER_ID_ACCROSS_SESSIONS or something like this, and then either the frontend or the cartservice could use a unique and common value (for example UUI.Empty or equivalent) in order to share the same SessionId/UserId and same cart in the redis database. Sharing my thoughts and findings for potential future implementation around this.
So maybe we want to rename this issue by Have an option to share a unique/common SessionId/UserId accross clusters for the cart?
These 2 PRS https://github.com/GoogleCloudPlatform/microservices-demo/pull/838 and https://github.com/GoogleCloudPlatform/microservices-demo/pull/1023 now allow to support this scenario.