This tutorial shows how to instantiate Redis and connect to it.
This example showcases how to instantiate Redis, connect a Pod to it, and send a PING command.
- Instantiate Redis
Note
This action may take 10+ min
apiVersion: cloud-resources.kyma-project.io/v1beta1
kind: GcpRedisInstance
metadata:
name: gcpredisinstance-simple-example
spec:
redisTier: "S1"
- Instantiate the redis-cli Pod
apiVersion: 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-example
- Exec into the Pod:
kubectl exec -i -t gcpredisinstance-simple-example-probe -c redis-cli -- sh -c "clear; (bash || ash || sh)"
- Exec a PING command:
redis-cli -h $HOST -p $PORT --tls --cacert /mnt/CaCert.pem PING
You should receive PONG
back from the server.
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
Note
This action may take 10+ min
apiVersion: 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: 45
- Instantiate the redis-cli Pod
apiVersion: 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-example
- Exec into the Pod:
kubectl exec -i -t gcpredisinstance-complex-example-probe -c redis-cli -- sh -c "clear; (bash || ash || sh)"
- Exec a PING command:
redis-cli -h $HOST -p $PORT -a $AUTH_STRING --tls --cacert /mnt/CaCert.pem PING
You should receive PONG
back from the server.