This topic demonstrates how you, as an app developer, connect your app to a Tanzu for Valkey on Kubernetes instance. The instructions show how a Valkey client (Valkey commander) can be used to connect to the existing Valkey instance and perform Valkey related operations.
Prepare
Before connecting an app to a Valkey instance, you must have:
-
The Kubernetes command line interface (kubectl) installed. For more information about kubectl, see the Kubernetes documentation.
-
A Valkey instance running in the same Kubernetes cluster as the app. The Valkey instance can be in a different namespace from the app. For information about creating an instance, see Create and delete Valkey instances.
To avoid Kubernetes permissions issues, you can grant developers admin access to their target namespace.
Create a key for a Valkey instance
To create a key for a Valkey instance:
-
Log in to the Valkey server by following the steps in Access Tanzu for Valkey on Kubernetes instances.
-
Set or get a key to store and retrieve the values. For example, the following commands create a
sample-key
key with valuesample-value
:$ 127.0.0.1:6379> set sample-key sample-value OK $ 127.0.0.1:6379> get sample-key "sample-value"
Connecting Valkey instance by using the Valkey Commander
Users can enable Valkey Commander to deploy along with a Valkey standalone, Valkey replication, or Valkey sentinel deployment. From the custom resource mentioned earlier, when spec.valkeyCommanderConfig.enabled
is set to true
and the corresponding Valkey Commander image is provided, the Valkey Commander is deployed automatically and connects to the corresponding Valkey instance.
Users can directly access the Valkey Commander by using the service that is exposed as ClusterIp
by port-forwarding, as mentioned in the Access Tanzu for Valkey on Kubernetes instances.
Content feedback and comments