Using GcpRedisInstance Custom Resources ​
The Cloud Manager module offers a GcpRedisInstance Custom Resource Definition (CRD). When you apply a GcpRedisInstance custom resource (CR), it creates a Memorystore for Redis instance that is reachable within your Kubernetes cluster network.
Prerequisites ​
You have the Cloud Manager module added.
Steps ​
Minimal Setup ​
This example showcases how to instantiate Redis using only the required fields, connect a Pod to it, and send a PING command.
Create a Redis instance. The operation may take more than 10 minutes.
yamlapiVersion: cloud-resources.kyma-project.io/v1beta1 kind: GcpRedisInstance metadata: name: gcpredisinstance-simple-example spec: redisTier: "S1"Instantiate the redis-cli Pod.
yamlapiVersion: v1 kind: Pod metadata: name: gcpredisinstance-simple-example-probe spec: containers: - name: redis-cli image: redis:latest command: ["/bin/sleep"] args: ["999999999999"] env: - name: HOST valueFrom: secretKeyRef: key: host name: gcpredisinstance-simple-example - name: PORT valueFrom: secretKeyRef: key: port name: gcpredisinstance-simple-example volumeMounts: - name: mounted mountPath: /mnt volumes: - name: mounted secret: secretName: gcpredisinstance-simple-exampleExecute into the Pod.
bashkubectl exec -i -t gcpredisinstance-simple-example-probe -c redis-cli -- sh -c "clear; (bash || ash || sh)"Run a PING command.
bashredis-cli -h $HOST -p $PORT --tls --cacert /mnt/CaCert.pem PINGYou should receive
PONGback from the server.
Advanced Setup ​
This example showcases how to instantiate Redis by using most of the spec fields, connect a Pod to it, and send a PING command.
Instantiate Redis. The operation may take more than 10 minutes.
yamlapiVersion: cloud-resources.kyma-project.io/v1beta1 kind: GcpRedisInstance metadata: name: gcpredisinstance-complex-example spec: redisTier: "P1" redisVersion: REDIS_7_2 authEnabled: true redisConfigs: maxmemory-policy: volatile-lru activedefrag: "yes" maintenancePolicy: dayOfWeek: day: "SATURDAY" startTime: hours: 15 minutes: 45Instantiate the redis-cli Pod.
yamlapiVersion: v1 kind: Pod metadata: name: gcpredisinstance-complex-example-probe spec: containers: - name: redis-cli image: redis:latest command: ["/bin/sleep"] args: ["999999999999"] env: - name: HOST valueFrom: secretKeyRef: key: host name: gcpredisinstance-complex-example - name: PORT valueFrom: secretKeyRef: key: port name: gcpredisinstance-complex-example - name: AUTH_STRING valueFrom: secretKeyRef: key: authString name: gcpredisinstance-complex-example volumeMounts: - name: mounted mountPath: /mnt volumes: - name: mounted secret: secretName: gcpredisinstance-complex-exampleExecute into the Pod.
bashkubectl exec -i -t gcpredisinstance-complex-example-probe -c redis-cli -- sh -c "clear; (bash || ash || sh)"Run a PING command.
bashredis-cli -h $HOST -p $PORT -a $AUTH_STRING --tls --cacert /mnt/CaCert.pem PINGYou should receive
PONGback from the server.