Using a Redis service
The YAML code below creates two objects: a VSHNRedis
instance and a pod accessing it to show information about the instance.
The latter references the redis-creds-connection
secret that will contain the access keys required to connect to the instance.
apiVersion: vshn.appcat.vshn.io/v1
kind: VSHNRedis
metadata:
name: my-redis-example
namespace: my-namespace
spec:
parameters:
service:
version: "7.0"
writeConnectionSecretToRef:
name: redis-creds-connection (1)
---
apiVersion: v1
kind: Pod
metadata:
name: redis-client
spec:
containers:
- name: redis
image: redis:7
command:
- /bin/sh
- -c
args:
- redis-cli -u rediss://$REDIS_USERNAME:$REDIS_PASSWORD@$REDIS_HOST:$REDIS_PORT --tls --cert /etc/redis-tls/tls.crt --key /etc/redis-tls/tls.key --cacert /etc/redis-tls/ca.crt INFO (3)
volumeMounts:
- name: redis-tls-secrets (4)
readOnly: true
mountPath: "/etc/redis-tls"
envFrom:
- secretRef:
name: redis-creds-connection (2)
volumes:
- name: redis-tls-secrets (4)
secret:
defaultMode: 0600
secretName: redis-creds-connection (2)
restartPolicy: Never
1 | The operator will create a secret with the access keys to connect to the instance. |
2 | The pod and the volume will use the new secret. |
3 | Uses redis-cli to print INFO into stdout. |
4 | Mount the secret with the credentials to the pod, for TLS support (enabled and enforced by default) |
Debug the service
To check the status and potential issues or errors in the service, check the status
field of the new object:
$ oc describe vshnredis.vshn.appcat.vshn.io my-redis-example
[...]
Status:
Certificate Debug:
Last Transition Time: 2023-02-17T23:25:58Z
Reason: Available
Status: True
Type: Ready
Last Transition Time: 2023-02-17T23:25:58Z
Reason: ReconcileSuccess
Status: True
Type: Synced
Conditions:
Last Transition Time: 2023-02-17T23:25:57Z
Reason: ReconcileSuccess
Status: True
Type: Synced
Last Transition Time: 2023-02-17T23:26:07Z
Reason: Available
Status: True
Type: Ready
Connection Details:
Last Published Time: 2023-02-17T23:26:07Z
Local CA Debug:
Last Transition Time: 2023-02-17T23:25:59Z
Reason: Available
Status: True
Type: Ready
Last Transition Time: 2023-02-17T23:25:58Z
Reason: ReconcileSuccess
Status: True
Type: Synced
Namespace Debug:
Last Transition Time: 2023-02-17T23:25:59Z
Reason: Available
Status: True
Type: Ready
Last Transition Time: 2023-02-17T23:25:58Z
Reason: ReconcileSuccess
Status: True
Type: Synced