Create a Valkey Instance
Create a Valkey (Redis-compatible) cache instance and mount its connection details in a Pod.
This guide creates an Amazon ElastiCache for Valkey instance from Kubernetes and mounts its connection details in a Pod. Valkey is compatible with Redis, so Redis clients such as redis-cli work with it.
You describe the cache with one manifest: ValkeyInstance. The platform creates the ElastiCache replication group in the elasticache subnets of your VPC, the security group and security group rules that let Pods reach it, and a Secret with the connection details in both Kubernetes and AWS Secrets Manager. A final snapshot on deletion is turned on for every instance, see EnvironmentConfig.
It is good practice to include the manifest in your application’s Helm chart, so the cache is deployed together with the application that uses it.
Prerequisites
Section titled “Prerequisites”Valkey is enabled by default. Your Infralib configuration needs:
| Module | Flag | Default | What it does |
|---|---|---|---|
platform-apis |
platform-apis.valkey.install |
true |
Installs the ValkeyInstance API. |
platform-apis |
platform-apis.postgresql.install |
true |
Also renders the shared database EnvironmentConfig that Valkey uses. Keep it true. |
crossplane-aws |
global.createObservers, global.createNamespacedObservers |
false |
Installs the ElastiCache and Secrets Manager providers and the elasticache subnet group lookup the instance needs. Set both to true. |
For the base modules every platform API needs, see Infralib Requirements.
1. Create the instance
Section titled “1. Create the instance”A ValkeyInstance works with an empty spec. Every field has a default:
apiVersion: database.entigo.com/v1alpha1kind: ValkeyInstancemetadata: name: example-valkeyspec: {}Watch it until READY is True:
kubectl get valkey example-valkey -wOptional settings
Section titled “Optional settings”| Field | Default | What it does |
|---|---|---|
instanceType |
cache.t4g.small |
ElastiCache node type. Sets memory, compute and network capacity. |
engineVersion |
unset | Valkey version, for example '8.2'. ElastiCache uses the latest patch version. |
numCacheClusters |
2 |
Nodes in the replication group: one primary plus replicas, 2–6. |
deletionProtection |
true |
Blocks deletion. Set to false before you delete the instance. |
snapshotRetentionLimit |
7 |
Days of automatic snapshots to keep, 0–35. 0 turns automatic backups off. |
snapshotWindow |
03:00-05:00 |
Daily snapshot time in UTC. Must not overlap with the maintenance window. |
maintenanceWindow |
sun:05:00-sun:06:00 |
Weekly maintenance time in UTC, at least 60 minutes. |
autoMinorVersionUpgrade |
true |
Applies minor engine upgrades in the maintenance window. |
parameterGroupName |
engine default | Uses an existing parameter group, for example 'default.valkey8'. |
parameterGroupParameters |
unset | Sets individual Valkey parameters, for example notify-keyspace-events: Ex. |
For example, a larger instance with three nodes and custom windows:
apiVersion: database.entigo.com/v1alpha1kind: ValkeyInstancemetadata: name: example-valkeyspec: engineVersion: '8.2' instanceType: 'cache.t4g.small' numCacheClusters: 3 maintenanceWindow: 'mon:00:00-mon:03:00' snapshotWindow: '05:00-06:00' snapshotRetentionLimit: 10 parameterGroupParameters: notify-keyspace-events: ExFor every field, see the ValkeyInstance API reference.
2. Mount the connection details in a Pod
Section titled “2. Mount the connection details in a Pod”The connection details are stored in the Kubernetes Secret and AWS Secrets Manager secret <metadata.name>-credentials. The Secret has the keys PRIMARY_ENDPOINT, READER_ENDPOINT, AUTH_TOKEN, PORT, and credentials.json with all four in one JSON document.
For more information about Secrets in Kubernetes, see Kubernetes documentation.
The simplest way is to load every key as an environment variable:
apiVersion: v1kind: Podmetadata: name: redisspec: containers: - name: redis image: redis:alpine command: ['sleep', 'infinity'] envFrom: - secretRef: name: example-valkey-credentialsTo pick individual keys, or to rename them, use secretKeyRef:
apiVersion: v1kind: Podmetadata: name: redisspec: containers: - name: redis image: redis:alpine command: ['sleep', 'infinity'] env: - name: PRIMARY_ENDPOINT valueFrom: secretKeyRef: name: example-valkey-credentials key: PRIMARY_ENDPOINT - name: READER_ENDPOINT valueFrom: secretKeyRef: name: example-valkey-credentials key: READER_ENDPOINT - name: AUTH_TOKEN valueFrom: secretKeyRef: name: example-valkey-credentials key: AUTH_TOKEN - name: PORT valueFrom: secretKeyRef: name: example-valkey-credentials key: PORTIf your application reads its configuration from a file, mount credentials.json:
apiVersion: v1kind: Podmetadata: name: redisspec: containers: - name: redis image: redis:alpine command: ['sleep', 'infinity'] volumeMounts: - name: credentials mountPath: /etc/credentials readOnly: true volumes: - name: credentials secret: secretName: example-valkey-credentials items: - key: credentials.json path: credentials.json3. Verify
Section titled “3. Verify”The instance is ready
Section titled “The instance is ready”The ValkeyInstance shows SYNCED and READY as True:
$ kubectl get valkeyNAME SYNCED READY COMPOSITION AGEexample-valkey True True valkeyinstances.database.entigo.com 20m29sThe Valkey instance appears in the AWS Console:

Connection details are stored
Section titled “Connection details are stored”$ kubectl get secretNAME TYPE DATA AGEexample-valkey-credentials Opaque 5 22m$ kubectl get secret example-valkey-credentials -o yamlapiVersion: v1kind: Secretmetadata: annotations: crossplane.io/composition-resource-name: credentials name: example-valkey-credentials namespace: <namespace>type: Opaquedata: PRIMARY_ENDPOINT: <base64-encoded-primary-endpoint> READER_ENDPOINT: <base64-encoded-reader-endpoint> AUTH_TOKEN: <base64-encoded-auth-token> PORT: <base64-encoded-port> credentials.json: <base64-encoded-credentials>The same details are in AWS Secrets Manager:

The Pod can connect
Section titled “The Pod can connect”With the environment variables mounted, connect over TLS:
$ kubectl get podNAME READY STATUS RESTARTS AGEredis 1/1 Running 0 10m
$ kubectl exec -it redis -- sh/ envPRIMARY_ENDPOINT=master.example-valkey.abc123.eun1.cache.amazonaws.comREADER_ENDPOINT=replica.example-valkey.abc123.eun1.cache.amazonaws.comAUTH_TOKEN=verysecretauthtokenPORT=6379
/ export REDISCLI_AUTH="$AUTH_TOKEN"
/ redis-cli --tls -h "$PRIMARY_ENDPOINT" -p "$PORT" PINGPONG
/ redis-cli --tls -h "$PRIMARY_ENDPOINT" -p "$PORT" SET testkey "hello"OK
/ redis-cli --tls -h "$PRIMARY_ENDPOINT" -p "$PORT" GET testkey"hello"With credentials.json mounted:
/ cat /etc/credentials/credentials.json{"AUTH_TOKEN": "verysecretauthtoken", "PORT": "6379", "PRIMARY_ENDPOINT": "master.example-valkey.abc123.eun1.cache.amazonaws.com", "READER_ENDPOINT": "replica.example-valkey.abc123.eun1.cache.amazonaws.com"}Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause / fix |
|---|---|
no matches for kind "ValkeyInstance" |
The API is not installed. Check the Prerequisites. |
SYNCED is False |
The platform could not create a cloud resource. kubectl describe valkey <name> shows the error under Conditions and Events. |
| The instance is not deleted | deletionProtection is true by default. Set it to false, apply, then delete. |
EnvironmentConfig
Section titled “EnvironmentConfig”One Valkey default is not configured on the ValkeyInstance object. It is set once for the whole cluster in the platform-apis EnvironmentConfig, so every instance gets the same protection without developers having to think about it.
| Setting | Default | What it does |
|---|---|---|
valkeyBackupBeforeDeletion |
true |
Takes a final snapshot before an instance is deleted, so the data can still be recovered. |
tags |
{} |
Cloud tags added to every Valkey resource. See Resource Tagging. |
valkeyBackupBeforeDeletion
Section titled “valkeyBackupBeforeDeletion”When enabled, deleting a ValkeyInstance takes one last snapshot before the instance disappears. That snapshot stays in AWS and can be used to bring the data back later.
Turning this off means a deleted instance is gone for good. Because Valkey is most often used as a cache that can simply be rebuilt, this is a reasonable setting to disable in environments where the contents are not worth keeping.
How many scheduled snapshots are kept, and when they are taken, is set per instance with spec.snapshotRetentionLimit and spec.snapshotWindow, see Optional settings. The cluster-wide backupRetentionPeriod setting applies to PostgreSQL and MariaDB only, not to Valkey.
Infralib Configuration Example
Section titled “Infralib Configuration Example”steps: ... - name: apps type: argocd-apps modules: ... - name: platform-apis source: platform-apis inputs: platform-apis: database: environmentConfig: valkeyBackupBeforeDeletion: true