Monitoring Redis on RedHat OpenShift with Instana
Redis is an open-source, in-memory key-value data store widely used for caching, real-time analytics, and message brokering. It provides high performance, scalability, and flexibility, making it a popular choice for cloud-native applications. You can monitor your Redis deployments on RedHat OpenShift Container Platform (OCP), an enterprise Kubernetes platform, by using Instana. Instana provides automated tracing, infrastructure monitoring, and observability for Redis-based microservices and cloud-native applications.
This blog discusses how to deploy Redis on Red Hat OCP and monitor it by using Instana.
Prerequisites
Ensure that the following prerequisites are met:
- Permissions to deploy workloads, Secrets, ConfigMaps, and Deployments in OCP.
- Instana agent is already installed and configured in the cluster.
Procedure
Notes
- All values (passwords, usernames, image paths, etc.) in this guide are examples only.
- Customize them based on your environment, security policies, and deployment needs.
- Use secure credentials and private image registries where applicable.
Step 1: Create a namespace (project)
Create a dedicated namespace for Redis and its monitoring.
oc new-project instana-agent
Step 2: Set up Redis Secrets
To set up Redis Secrets, complete the following steps:
1. Create a Secret to store Redis credentials securely:
apiVersion: v1
kind: Secret
metadata:
name: instana-agent-redis1
namespace: instana-agent
type: Opaque
data:
INSTANA_REDIS_USERNAME: ZGVmYXVsdA==
INSTANA_REDIS_PASSWORD: c2VjdXJlcGFzcw==
2. Apply the Secret:
oc apply -f redis-secret.yaml
The following image displays the Redis Secret:
Step 3: Configure Redis
1. Create Redis ConfigMap: The ConfigMap provides the Redis configuration to enforce secure authentication as shown in the following example:
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-config
namespace: instana-agent
data:
redis.conf: |
requirepass "$(REDIS_PASSWORD)"
set-proc-title no
2. Apply the ConfigMap:
oc apply -f redis-config.yaml
The following image displays the Redis ConfigMap:
Step 4: Deploy Redis instance
To deploy the Redis instance, complete the following steps:
1. Create a yaml file to define how Redis must be deployed on OpenShift by using Kubernetes as shown in the following example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis1
namespace: instana-agent
spec:
replicas: 1
selector:
matchLabels:
app: redis1
template:
metadata:
labels:
app: redis1
spec:
containers:
- name: redis1
image: image-registry.openshift-image-registry.svc:5000/instana-agent/redis:8.2.0
ports:
- containerPort: 6379
env:
- name: REDIS_USERNAME
valueFrom:
secretKeyRef:
name: instana-agent-redis1
key: INSTANA_REDIS_USERNAME
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: instana-agent-redis1
key: INSTANA_REDIS_PASSWORD
command: ["/bin/sh", "-c"]
args:
- redis-server /opt/bitnami/redis/etc/redis.conf --requirepass "$REDIS_PASSWORD" --set-proc-title no
volumeMounts:
- name: redis-config-volume
mountPath: /opt/bitnami/redis/etc/redis.conf
subPath: redis.conf
volumes:
- name: redis-config-volume
configMap:
name: redis-config
2. Apply and roll out the deployment:
oc apply -f redis-deployment.yaml
oc rollout restart deployment redis1
The following image displays the Redis deployment:
Step 5: Configure Instana agent to detect Redis
The Instana agent automatically detects the Redis instance and collects performance metrics based on the configuration.
The following image displays the Instana agent comfiguration yaml file in the Redis namespace:
The following snippet presents the Instana agent configuration:
configuration.yaml: |
com.instana.plugin.redis:
username:
configuration_from:
type: env
env_name: REDIS_USERNAME
#default_value: default
password:
configuration_from:
type: env
env_name: REDIS_PASSWORD
#default_value: securepass1
config-command: CONFIG
Step 6: Monitor Redis on the Instana UI
Once Redis is deployed and monitored, you can view its health and performance metrics in the Instana ui.
To view the Redis metrics, complete the following steps in the Instana UI:
1. From the navigation menu, click Infrastructure.
2. In the Map tab, click a Redis host that is monitored.
3. Click the Redis node.
The following image shows the Redis nodes in the Infrastructure page in the Instana UI:
The following image displays metrics related to the Redis node
Considerations for monitoring multiple Redis instances
When deploying and monitoring multiple Redis instances in OpenShift with Instana, follow these best practices to avoid configuration conflicts and ensure proper monitoring:
- Separate namespace per instance
Each Redis instance must run in its own namespace to avoid conflicts between configurations and secrets.
- Set `set-proc-title no` in `redis.conf`
- If process environment variables are used to configure the Redis plug-in, make sure to set the `set-proc-title no` flag to `no` in the `redis.conf` file as shown in the following example:
set-proc-title no
- Username configuration
By default, set the username as `default` for every Redis instance.
- Different usernames per instance
If you want to use different usernames for each instance, make sure to disable protected mode by adding the following line in the `redis.conf`file:
protected-mode no
- This configuration allows non-default usernames to be used for authentication without issues.
- Secret and ConfigMap per namespace
Create separate Secrets and ConfigMaps for every Redis instance in its namespace, containing the correct credentials and configuration values.
Conclusion
Deploying and monitoring Redis in OpenShift by using Instana enables real-time observability and performance insights of your Redis-based services.
By following the best practices outlined here and properly configuring multiple Redis instances, you can ensure robust monitoring with no configuration conflicts.
#Documentation#Kubernetes