Access Redis CLI via Port Forward#
This documentation will help to connect to managed Redis via redis-cli
using port forward.
CLI Setup#
The first step is to setup redis-cli
on your local machine. For this, go through following steps. If you already have CLI setup, you can skip this section.
- Run following command in terminal
- Run following command to verify CLI installation.
Create Port Forwarding to Redis Service#
Before running redis-cli
command we need to port forward to Redis service running in cluster. To achieve this, perform following steps:
- In OpenShift console, click on your username on top right corner and click
Copy login command
as shown below: - Click on
Display Token
and then copyoc login
command. - Run this command inside your terminal. Now you have access to interact with your cluster using terminal.
- Run following command to locate service to which we need to create port forward.
Here <redis-namespace>
is the name of namespace where Redis is deployed (In current case its value is bitnami-redis
). This name might be different for you. You can ask about this to cluster admin.
- You'll get an output similar to one shown below:
- Run the following command to create port forward.
- `<service-name>` is the name of service that has `CLUSTER-IP` assigned. In current case its value is `bitnami-redis`.
- `<port>` is the port number for this service to which we need to create port forward. For sentinel mode we need to port forward to port `26379` otherwise to `6379`.
- This should result in following output:
- At this moment, you need to open a second terminal (while keeping this running) and run following command:
- Here `<password>` should be replaced by password used to connect to Redis. This password can easily be retrieved from Vault.