Local Redis
Overview
Redis, known as an advanced key-value store, offers a fast and efficient solution for managing data in-memory. Redis' speed and simplicity make it the preferred choice for applications requiring rapid access to cached information, real-time analytics, and message brokering. Redis supports a variety of data structures, including strings, hashes, lists, sets, and more, allowing users to model and manipulate data based on their specific requirements.
Below you can find the Aembit configuration required to work with Redis as a Server Workload using the Redis-compatible CLI, application, or a library.
Prerequisites
Before proceeding with the configuration, ensure you have access to a Kubernetes cluster. Modify the example YAML file according to your specific configurations, and then deploy it to your Kubernetes cluster.
Example Redis Yaml File
Note: This example does not use TLS and is shown here for demonstration purposes only. It is strongly recommended to use TLS in production settings.
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
spec:
replicas: 1
selector:
matchLabels:
app: redis
strategy:
type: Recreate
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis
imagePullPolicy: Always
ports:
- containerPort: 6379
name: redis
env:
- name: MASTER
value: "true"
- name: REDIS_USER
value: "<master user name>"
- name: REDIS_PASSWORD
value: "<master password>"
---
# Service
apiVersion: v1
kind: Service
metadata:
name: redis
spec:
type: NodePort
selector:
app: redis
ports:
- port: 6379
targetPort: 6379
⚠️ Before running the command, ensure you have replaced the master user name and master password in the configuration file with your desired values.
Use the following command to deploy this file to your Kubernetes cluster.
kubectl apply -f ./redis.yaml
Server Workload Configuration
- Create a new Server Workload.
- Name - Choose a user-friendly name.
- Configure the service endpoint:
- Host - redis.default.svc.cluster.local
- Application Protocol - Redis
- Port - 6379
- Forward to Port - 6379
- Authentication method - Password Authentication
- Authentication scheme - Password
Credential Provider Configuration
- Create a new Credential Provider.
- Name - Choose a user-friendly name.
- Credential Type - Username & Password
- Username - Provide the login ID for the Redis master user.
- Password - Provide the master password associated with the Redis credentials.
Client Workload Configuration
Aembit now handles the credentials required to access the Server Workload, eliminating the need for you to manage them directly. You can safely remove any previously used credentials from the Client Workload.
If you access the Server Workload through an SDK or library, it is possible that the SDK/library may still require credentials to be present for initialization purposes. In this scenario, you can provide placeholder credentials. Aembit will overwrite these placeholder credentials with the appropriate ones during the access process.
Access Policy
- Create an access policy for a Client Workload to access the Redis Server Workload and assign the newly created Credential Provider to it.