kustomize/components/memorystore/README.md
By default the cartservice app is serializing the data in an in-cluster Redis database. Using a database outside your GKE cluster could bring more resiliency and more security with a managed service like Google Cloud Memorystore (Redis).
Important notes:
To provision a Memorystore (Redis) instance you can follow the following instructions:
ZONE="<your-GCP-zone>"
REGION="<your-GCP-region>"
gcloud services enable redis.googleapis.com
gcloud redis instances create redis-cart \
--size=1 \
--region=${REGION} \
--zone=${ZONE} \
--redis-version=redis_7_0
Note: You can also find in this repository the Terraform script to provision the Memorystore (Redis) instance alongside the GKE cluster, more information here.
To automate the deployment of Online Boutique integrated with Memorystore (Redis) you can leverage the following variation with Kustomize.
From the kustomize/ folder at the root level of this repository, execute this command:
kustomize edit add component components/memorystore
Note: this Kustomize component will also remove the redis-cart Deployment and Service not used anymore.
This will update the kustomize/kustomization.yaml file which could be similar to:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- base
components:
- components/memorystore
Update current Kustomize manifest to target this Memorystore (Redis) instance.
REDIS_IP=$(gcloud redis instances describe redis-cart --region=${REGION} --format='get(host)')
REDIS_PORT=$(gcloud redis instances describe redis-cart --region=${REGION} --format='get(port)')
sed -i "s/REDIS_CONNECTION_STRING/${REDIS_IP}:${REDIS_PORT}/g" components/memorystore/kustomization.yaml
You can locally render these manifests by running kubectl kustomize . as well as deploying them by running kubectl apply -k ..