From 8b307688f2fed211297328e54da30df06417a0e9 Mon Sep 17 00:00:00 2001 From: tpmccallum Date: Fri, 22 Mar 2024 12:10:57 +1000 Subject: [PATCH 1/4] Add Redis trigger application tutorial Signed-off-by: tpmccallum --- .../tutorials/pub-sub-with-redis.md | 213 ++++++++++++++++++ 1 file changed, 213 insertions(+) create mode 100644 content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md diff --git a/content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md b/content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md new file mode 100644 index 0000000..9ce8b73 --- /dev/null +++ b/content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md @@ -0,0 +1,213 @@ +--- +title: Publish-Subscribe With Redis +description: Learn how to create a Spin application that responds to messages on pub-sub Redis channels and runs in Kubernetes +categories: [Spin Operator] +tags: [Tutorials] +weight: 100 +--- + +## Prerequisites + +For this tutorial, we will be using: +- [Spin](https://developer.fermyon.com/spin/v2/install) to build and deploy our event-driven WebAssembly application, +- [Redis](https://redis.io/docs/install/install-redis/) to generate events in our real-time messaging scenario, and +- [Rancher Desktop](https://rancherdesktop.io/) to manage Kubernetes on our Desktop. ([This page](../../spin-operator/tutorials/integrating-with-rancher-desktop.md) documents integrating Rancher Desktop and SpinKube.) + +## Create a Kubernetes Cluster + +First, we create our Kubernetes cluster: + +```bash +k3d cluster create wasm-cluster --image ghcr.io/spinkube/containerd-shim-spin/k3d:v0.13.1 -p "8081:80@loadbalancer" --agents 2 +``` + +## Install CRDs for SpinKube + +Next, we apply the necessary Custom Resource Definitions (CRDs) to our Kubernetes cluster: + +```bash +kubectl apply -f https://github.com/spinkube/spin-operator/releases/download/v0.1.0/spin-operator.crds.yaml +kubectl apply -f https://github.com/spinkube/spin-operator/releases/download/v0.1.0/spin-operator.runtime-class.yaml +kubectl apply -f https://github.com/spinkube/spin-operator/releases/download/v0.1.0/spin-operator.shim-executor.yaml +``` + +## Install Spin Operator + +Then, we install Spin Operator which handles the `SpinApp` application that we are about to create: + +```bash +helm install spin-operator \ + --namespace spin-operator \ + --create-namespace \ + --version 0.1.0 \ + --wait \ + oci://ghcr.io/spinkube/charts/spin-operator +``` + +## Redis + +Let's dive in and get Redis sorted because we are going to need information about our Redis installation in our Spin application's config. We will use the following `helm` commands to get the job done: + +```bash +helm repo add bitnami https://charts.bitnami.com/bitnami +helm repo update +helm install my-redis bitnami/redis +``` + +The `helm` installation process from above prints a lot of useful information to the terminal. For example, the endpoints to communicate with Redis (read/write vs read-only): + +```bash +my-redis-master.default.svc.cluster.local for read/write operations (port 6379) +my-redis-replicas.default.svc.cluster.local for read-only operations (port 6379) +``` + +In addition, there are pre-written commands that you can cut and paste. For example: + +```bash +export REDIS_PASSWORD=$(kubectl get secret --namespace default my-redis -o jsonpath="{.data.redis-password}" | base64 -d) +``` + +Go ahead and run the command above to set the password. And, if need be, you can run the following command to see the actual password printed in your terminal: + +```bash +echo $REDIS_PASSWORD +``` + +## Create a Redis Message Handler Using Rust + +We use Spin's convenient `redis-rust` template to scaffold our Rust-based Redis message handler: + +```bash +spin new -t redis-rust redis-message-handler +``` + +The command above will provide the prompts for you to add the Description, Redis address and Redis channel (We use the `my-redis-master.default.svc.cluster.local` from above to help configure the Redis address, and the channel is arbitrary i.e. `channel-one`): + +```bash +Description: Redis message handler using Rust +Redis address[redis://localhost:6379]: redis://my-redis-master.default.svc.cluster.local:6379 +Redis channel: channel-one +``` + +## Configure Spin Application + +We change into our application directory, and can see the layout that Spin has scaffolded for us: + +```bash +cd redis-message-handler +tree . +``` + +The above `tree .` command, produces the following output: + +```bash +. +├── Cargo.toml +├── spin.toml +└── src + └── lib.rs +``` + +If we open the application manifest (`spin.toml` file) we see that Spin has already pre-populated the [Redis trigger configuration](https://developer.fermyon.com/spin/v2/redis-trigger#the-spin-redis-trigger): + +```toml +// --snip -- +[application.trigger.redis] +address = "redis://my-redis-master.default.svc.cluster.local:6379" + +[[trigger.redis]] +channel = "channel-one" +component = "redis-message-handler" +// --snip -- +``` + +By default, Spin does not authenticate to Redis. You can work around this by providing the password in the `redis://` URL. For example: `address = "redis://:p4ssw0rd@localhost:6379"` + +> Do not use passwords in code committed to version control systems. + +## Application Logic + +In this example, we want to write the logic for our Spin application to listen to messages published on `channel-one`. So, we open the `src/lib.rs` file and paste the following code: + +```rust +use anyhow::Result; +use bytes::Bytes; +use spin_sdk::redis_component; +use std::str::from_utf8; + +/// A simple Spin Redis component. +#[redis_component] +fn on_message(message: Bytes) -> Result<()> { + println!("{}", from_utf8(&message)?); + Ok(()) +} +``` + +## Build + +With the logic and configuration in place, we can build the Spin application: + +```bash +spin build +``` + +## Publish + +We will now push the application image to a registry. You can use any container registry you prefer (like DockerHub). But for this tutorial, we’ll use a simple one that does not require authentication: + +```bash +spin registry push ttl.sh/redis-message-handler:0.1.0 +``` + +To read the configuration we can use the `spin scaffold` command: + +```bash +spin kube scaffold --from ttl.sh/redis-message-handler:0.1.0 +``` + +As we can see, our `SpinApp` is all set and using the `containerd-shim-spin` executor: + +```yaml +apiVersion: core.spinoperator.dev/v1alpha1 +kind: SpinApp +metadata: + name: redis-message-handler +spec: + image: "ttl.sh/redis-message-handler:0.1.0" + executor: containerd-shim-spin + replicas: 2 +``` + +## Deploy + +We deploy our application to our cluster using the `spin kube` command: + +```bash +spin kube deploy --from ttl.sh/redis-message-handler:0.1.0 +``` + +## Test + +We want to run the Redis server and publish a message. First, we run the Redis container image: + +```bash +kubectl run --namespace default redis-client --restart='Never' --env REDIS_PASSWORD=$REDIS_PASSWORD --image docker.io/bitnami/redis:7.2.4-debian-12-r9 --command -- sleep infinity +``` + +Then, we want to attach to the pod: + +```bash +kubectl exec --tty -i redis-client --namespace default -- bash +``` + +And, access the Redis CLI from inside the cluster: + +```bash +REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli -h my-redis-master +``` + +Which then provides us with the prompt (`my-redis-master:6379>`) at which point we can publish our message: + +```bash +my-redis-master:6379> PUBLISH channel-one message-one +``` \ No newline at end of file From 6fe810cde91fdf206e35ef557957411d8a2dccdd Mon Sep 17 00:00:00 2001 From: tpmccallum Date: Mon, 15 Apr 2024 21:55:41 +1000 Subject: [PATCH 2/4] First round of content in response to comments - more testing underway Signed-off-by: tpmccallum --- .../tutorials/pub-sub-with-redis.md | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md b/content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md index 9ce8b73..9530ad4 100644 --- a/content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md +++ b/content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md @@ -1,6 +1,6 @@ --- title: Publish-Subscribe With Redis -description: Learn how to create a Spin application that responds to messages on pub-sub Redis channels and runs in Kubernetes +description: Learn how to create a Spin App that responds to messages on pub-sub Redis channels and runs in Kubernetes categories: [Spin Operator] tags: [Tutorials] weight: 100 @@ -9,9 +9,8 @@ weight: 100 ## Prerequisites For this tutorial, we will be using: -- [Spin](https://developer.fermyon.com/spin/v2/install) to build and deploy our event-driven WebAssembly application, -- [Redis](https://redis.io/docs/install/install-redis/) to generate events in our real-time messaging scenario, and -- [Rancher Desktop](https://rancherdesktop.io/) to manage Kubernetes on our Desktop. ([This page](../../spin-operator/tutorials/integrating-with-rancher-desktop.md) documents integrating Rancher Desktop and SpinKube.) +- [Spin](https://developer.fermyon.com/spin/v2/install) to build and deploy our event-driven WebAssembly application, and +- [Redis](https://redis.io/docs/install/install-redis/) to generate events in our real-time messaging scenario. ## Create a Kubernetes Cluster @@ -23,9 +22,10 @@ k3d cluster create wasm-cluster --image ghcr.io/spinkube/containerd-shim-spin/k3 ## Install CRDs for SpinKube -Next, we apply the necessary Custom Resource Definitions (CRDs) to our Kubernetes cluster: +Next, we install cert-manager and apply the necessary Runtime Class and Custom Resource Definitions (CRDs) to our Kubernetes cluster: ```bash +kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.3/cert-manager.yaml kubectl apply -f https://github.com/spinkube/spin-operator/releases/download/v0.1.0/spin-operator.crds.yaml kubectl apply -f https://github.com/spinkube/spin-operator/releases/download/v0.1.0/spin-operator.runtime-class.yaml kubectl apply -f https://github.com/spinkube/spin-operator/releases/download/v0.1.0/spin-operator.shim-executor.yaml @@ -46,12 +46,12 @@ helm install spin-operator \ ## Redis -Let's dive in and get Redis sorted because we are going to need information about our Redis installation in our Spin application's config. We will use the following `helm` commands to get the job done: +Let's dive in and install Redis because we need information about the Redis instance to configure our Spin App. We will use the following helm commands to get the job done: ```bash helm repo add bitnami https://charts.bitnami.com/bitnami helm repo update -helm install my-redis bitnami/redis +helm install my-redis bitnami/redis --set auth.enabled=false ``` The `helm` installation process from above prints a lot of useful information to the terminal. For example, the endpoints to communicate with Redis (read/write vs read-only): @@ -61,13 +61,13 @@ my-redis-master.default.svc.cluster.local for read/write operations (port 6379) my-redis-replicas.default.svc.cluster.local for read-only operations (port 6379) ``` -In addition, there are pre-written commands that you can cut and paste. For example: +In addition, there are pre-written commands that you can copy and paste. For example: ```bash export REDIS_PASSWORD=$(kubectl get secret --namespace default my-redis -o jsonpath="{.data.redis-password}" | base64 -d) ``` -Go ahead and run the command above to set the password. And, if need be, you can run the following command to see the actual password printed in your terminal: +Go ahead and run the command above to store the password as an environment variable for the current terminal session. If required, you can print the actual password using: ```bash echo $REDIS_PASSWORD @@ -111,18 +111,16 @@ The above `tree .` command, produces the following output: If we open the application manifest (`spin.toml` file) we see that Spin has already pre-populated the [Redis trigger configuration](https://developer.fermyon.com/spin/v2/redis-trigger#the-spin-redis-trigger): ```toml -// --snip -- +# --snip -- [application.trigger.redis] address = "redis://my-redis-master.default.svc.cluster.local:6379" [[trigger.redis]] channel = "channel-one" component = "redis-message-handler" -// --snip -- +# --snip -- ``` -By default, Spin does not authenticate to Redis. You can work around this by providing the password in the `redis://` URL. For example: `address = "redis://:p4ssw0rd@localhost:6379"` - > Do not use passwords in code committed to version control systems. ## Application Logic @@ -159,7 +157,9 @@ We will now push the application image to a registry. You can use any container spin registry push ttl.sh/redis-message-handler:0.1.0 ``` -To read the configuration we can use the `spin scaffold` command: +> This image will be available for the default time of 24h (because we're using a server tag instead of specifying a duration for the image to live). + +To create the Kubernetes deployment manifest we can use the `spin kube scaffold` command: ```bash spin kube scaffold --from ttl.sh/redis-message-handler:0.1.0 @@ -180,21 +180,26 @@ spec: ## Deploy -We deploy our application to our cluster using the `spin kube` command: +We deploy the Spin App to our Kubernetes cluster by piping the deployment manifest to kubectl: ```bash -spin kube deploy --from ttl.sh/redis-message-handler:0.1.0 +spin kube scaffold --from ttl.sh/redis-message-handler:0.1.0 | kubectl apply -f - ``` ## Test -We want to run the Redis server and publish a message. First, we run the Redis container image: +To test the application, we will run an additional container for publishing messages to our Redis channel: ```bash -kubectl run --namespace default redis-client --restart='Never' --env REDIS_PASSWORD=$REDIS_PASSWORD --image docker.io/bitnami/redis:7.2.4-debian-12-r9 --command -- sleep infinity +kubectl run redis-client \ + --namespace default \ + --restart='Never' \ + --env REDIS_PASSWORD=$REDIS_PASSWORD \ + --image docker.io/bitnami/redis:7.2.4-debian-12-r9 \ + --command -- sleep infinity ``` -Then, we want to attach to the pod: +Then, we want to jump into the container using `kubectl exec`: ```bash kubectl exec --tty -i redis-client --namespace default -- bash From 3d5e4dc7421c0bcfcf03b9966fdd50f901d1686a Mon Sep 17 00:00:00 2001 From: tpmccallum Date: Mon, 15 Apr 2024 22:20:53 +1000 Subject: [PATCH 3/4] Second round of content in response to comments Signed-off-by: tpmccallum --- .../spin-operator/tutorials/pub-sub-with-redis.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md b/content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md index 9530ad4..9e49fd2 100644 --- a/content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md +++ b/content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md @@ -51,7 +51,7 @@ Let's dive in and install Redis because we need information about the Redis inst ```bash helm repo add bitnami https://charts.bitnami.com/bitnami helm repo update -helm install my-redis bitnami/redis --set auth.enabled=false +helm install my-redis bitnami/redis ``` The `helm` installation process from above prints a lot of useful information to the terminal. For example, the endpoints to communicate with Redis (read/write vs read-only): @@ -85,7 +85,7 @@ The command above will provide the prompts for you to add the Description, Redis ```bash Description: Redis message handler using Rust -Redis address[redis://localhost:6379]: redis://my-redis-master.default.svc.cluster.local:6379 +Redis address[redis://localhost:6379]: redis://:@my-redis-master.default.svc.cluster.local:6379 Redis channel: channel-one ``` @@ -113,7 +113,7 @@ If we open the application manifest (`spin.toml` file) we see that Spin has alre ```toml # --snip -- [application.trigger.redis] -address = "redis://my-redis-master.default.svc.cluster.local:6379" +address = "redis://:password@my-redis-master.default.svc.cluster.local:6379" [[trigger.redis]] channel = "channel-one" @@ -137,6 +137,7 @@ use std::str::from_utf8; #[redis_component] fn on_message(message: Bytes) -> Result<()> { println!("{}", from_utf8(&message)?); + // Implement me ... Ok(()) } ``` @@ -208,11 +209,11 @@ kubectl exec --tty -i redis-client --namespace default -- bash And, access the Redis CLI from inside the cluster: ```bash -REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli -h my-redis-master +REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli -h my-redis-master.default.svc.cluster.local ``` -Which then provides us with the prompt (`my-redis-master:6379>`) at which point we can publish our message: +This provides us with the following prompt at which point we can publish our message: ```bash -my-redis-master:6379> PUBLISH channel-one message-one +my-redis-master.default.svc.cluster.local:6379> PUBLISH channel-one message-one ``` \ No newline at end of file From c134e5ca7118e594044fb20943de8dee93b76ae2 Mon Sep 17 00:00:00 2001 From: tpmccallum Date: Tue, 16 Apr 2024 17:11:06 +1000 Subject: [PATCH 4/4] Use Valkey Signed-off-by: tpmccallum --- ...b-with-redis.md => pub-sub-with-valkey.md} | 69 ++++++++++--------- 1 file changed, 35 insertions(+), 34 deletions(-) rename content/en/docs/spin-operator/tutorials/{pub-sub-with-redis.md => pub-sub-with-valkey.md} (65%) diff --git a/content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md b/content/en/docs/spin-operator/tutorials/pub-sub-with-valkey.md similarity index 65% rename from content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md rename to content/en/docs/spin-operator/tutorials/pub-sub-with-valkey.md index 9e49fd2..94fa34e 100644 --- a/content/en/docs/spin-operator/tutorials/pub-sub-with-redis.md +++ b/content/en/docs/spin-operator/tutorials/pub-sub-with-valkey.md @@ -1,6 +1,6 @@ --- -title: Publish-Subscribe With Redis -description: Learn how to create a Spin App that responds to messages on pub-sub Redis channels and runs in Kubernetes +title: Publish-Subscribe With Valkey +description: Learn how to create a Spin App that responds to messages on pub-sub Valkey channels and runs in Kubernetes categories: [Spin Operator] tags: [Tutorials] weight: 100 @@ -10,7 +10,7 @@ weight: 100 For this tutorial, we will be using: - [Spin](https://developer.fermyon.com/spin/v2/install) to build and deploy our event-driven WebAssembly application, and -- [Redis](https://redis.io/docs/install/install-redis/) to generate events in our real-time messaging scenario. +- [Valkey](https://valkey.io/docs/) to generate events in our real-time messaging scenario. ## Create a Kubernetes Cluster @@ -44,48 +44,48 @@ helm install spin-operator \ oci://ghcr.io/spinkube/charts/spin-operator ``` -## Redis +## Valkey -Let's dive in and install Redis because we need information about the Redis instance to configure our Spin App. We will use the following helm commands to get the job done: +Let's dive in and install Valkey because we need information about the Valkey instance to configure our Spin App. We will use the following helm commands to get the job done: ```bash helm repo add bitnami https://charts.bitnami.com/bitnami helm repo update -helm install my-redis bitnami/redis +helm install my-Valkey bitnami/Valkey ``` -The `helm` installation process from above prints a lot of useful information to the terminal. For example, the endpoints to communicate with Redis (read/write vs read-only): +The `helm` installation process from above prints a lot of useful information to the terminal. For example, the endpoints to communicate with Valkey (read/write vs read-only): ```bash -my-redis-master.default.svc.cluster.local for read/write operations (port 6379) -my-redis-replicas.default.svc.cluster.local for read-only operations (port 6379) +my-Valkey-master.default.svc.cluster.local for read/write operations (port 6379) +my-Valkey-replicas.default.svc.cluster.local for read-only operations (port 6379) ``` In addition, there are pre-written commands that you can copy and paste. For example: ```bash -export REDIS_PASSWORD=$(kubectl get secret --namespace default my-redis -o jsonpath="{.data.redis-password}" | base64 -d) +export Valkey_PASSWORD=$(kubectl get secret --namespace default my-valkey -o jsonpath="{.data.valkey-password}" | base64 -d) ``` Go ahead and run the command above to store the password as an environment variable for the current terminal session. If required, you can print the actual password using: ```bash -echo $REDIS_PASSWORD +echo $VALKEY_PASSWORD ``` -## Create a Redis Message Handler Using Rust +## Create a Valkey Message Handler Using Rust -We use Spin's convenient `redis-rust` template to scaffold our Rust-based Redis message handler: +We use Spin's convenient `valkey-rust` template to scaffold our Rust-based Valkey message handler: ```bash -spin new -t redis-rust redis-message-handler +spin new -t redis-rust valkey-message-handler ``` -The command above will provide the prompts for you to add the Description, Redis address and Redis channel (We use the `my-redis-master.default.svc.cluster.local` from above to help configure the Redis address, and the channel is arbitrary i.e. `channel-one`): +The command above will provide the prompts for you to add the Description, Valkey address and Valkey channel (We use the `my-valkey-master.default.svc.cluster.local` from above to help configure the Valkey address, and the channel is arbitrary i.e. `channel-one`): ```bash -Description: Redis message handler using Rust -Redis address[redis://localhost:6379]: redis://:@my-redis-master.default.svc.cluster.local:6379 +Description: Valkey message handler using Rust +Redis address[valkey://localhost:6379]: valkey://:@my-valkey-master.default.svc.cluster.local:6379 Redis channel: channel-one ``` @@ -94,7 +94,7 @@ Redis channel: channel-one We change into our application directory, and can see the layout that Spin has scaffolded for us: ```bash -cd redis-message-handler +cd valkey-message-handler tree . ``` @@ -108,16 +108,16 @@ The above `tree .` command, produces the following output: └── lib.rs ``` -If we open the application manifest (`spin.toml` file) we see that Spin has already pre-populated the [Redis trigger configuration](https://developer.fermyon.com/spin/v2/redis-trigger#the-spin-redis-trigger): +If we open the application manifest (`spin.toml` file) we see that Spin has already pre-populated the [Valkey trigger configuration](https://developer.fermyon.com/spin/v2/redis-trigger#the-spin-redis-trigger): ```toml # --snip -- [application.trigger.redis] -address = "redis://:password@my-redis-master.default.svc.cluster.local:6379" +address = "valkey://:password@my-valkey-master.default.svc.cluster.local:6379" [[trigger.redis]] channel = "channel-one" -component = "redis-message-handler" +component = "valkey-message-handler" # --snip -- ``` @@ -133,7 +133,7 @@ use bytes::Bytes; use spin_sdk::redis_component; use std::str::from_utf8; -/// A simple Spin Redis component. +/// A simple Spin Valkey component. #[redis_component] fn on_message(message: Bytes) -> Result<()> { println!("{}", from_utf8(&message)?); @@ -155,7 +155,7 @@ spin build We will now push the application image to a registry. You can use any container registry you prefer (like DockerHub). But for this tutorial, we’ll use a simple one that does not require authentication: ```bash -spin registry push ttl.sh/redis-message-handler:0.1.0 +spin registry push ttl.sh/valkey-message-handler:0.1.0 ``` > This image will be available for the default time of 24h (because we're using a server tag instead of specifying a duration for the image to live). @@ -163,7 +163,7 @@ spin registry push ttl.sh/redis-message-handler:0.1.0 To create the Kubernetes deployment manifest we can use the `spin kube scaffold` command: ```bash -spin kube scaffold --from ttl.sh/redis-message-handler:0.1.0 +spin kube scaffold --from ttl.sh/valkey-message-handler:0.1.0 ``` As we can see, our `SpinApp` is all set and using the `containerd-shim-spin` executor: @@ -172,9 +172,9 @@ As we can see, our `SpinApp` is all set and using the `containerd-shim-spin` exe apiVersion: core.spinoperator.dev/v1alpha1 kind: SpinApp metadata: - name: redis-message-handler + name: valkey-message-handler spec: - image: "ttl.sh/redis-message-handler:0.1.0" + image: "ttl.sh/valkey-message-handler:0.1.0" executor: containerd-shim-spin replicas: 2 ``` @@ -184,18 +184,19 @@ spec: We deploy the Spin App to our Kubernetes cluster by piping the deployment manifest to kubectl: ```bash -spin kube scaffold --from ttl.sh/redis-message-handler:0.1.0 | kubectl apply -f - +spin kube scaffold --from ttl.sh/valkey-message-handler:0.1.0 | kubectl apply -f - ``` ## Test -To test the application, we will run an additional container for publishing messages to our Redis channel: +To test the application, we will run an additional container for publishing messages to our Valkey channel: ```bash -kubectl run redis-client \ +kubectl run valkey-client \ --namespace default \ --restart='Never' \ - --env REDIS_PASSWORD=$REDIS_PASSWORD \ + --env VALKEY_PASSWORD=$VALKEY_PASSWORD \ + # TODO new way of installing valkey --image docker.io/bitnami/redis:7.2.4-debian-12-r9 \ --command -- sleep infinity ``` @@ -203,17 +204,17 @@ kubectl run redis-client \ Then, we want to jump into the container using `kubectl exec`: ```bash -kubectl exec --tty -i redis-client --namespace default -- bash +kubectl exec --tty -i valkey-client --namespace default -- bash ``` -And, access the Redis CLI from inside the cluster: +And, access the Valkey CLI from inside the cluster: ```bash -REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli -h my-redis-master.default.svc.cluster.local +VALKEYCLI_AUTH="$VALKEY_PASSWORD" valkey-cli -h my-valkey-master.default.svc.cluster.local ``` This provides us with the following prompt at which point we can publish our message: ```bash -my-redis-master.default.svc.cluster.local:6379> PUBLISH channel-one message-one +my-valkey-master.default.svc.cluster.local:6379> PUBLISH channel-one message-one ``` \ No newline at end of file