100 Days of DevOps: Day 65

Deploy Redis Deployment on Kubernetes

Introduction

This article details the precise steps and Kubernetes configuration used to successfully deploy a single, dedicated Redis cache instance on the cluster for initial testing.

The d…


This content originally appeared on DEV Community and was authored by Wycliffe A. Onyango

Deploy Redis Deployment on Kubernetes

Introduction

This article details the precise steps and Kubernetes configuration used to successfully deploy a single, dedicated Redis cache instance on the cluster for initial testing.

The deployment leverages essential Kubernetes primitives—ConfigMap, Deployment, and VolumeMounts—to ensure a scalable, configurable, and ephemeral testing environment.

Step 1: Configuring Redis with a ConfigMap

Before deploying the Redis application, the team needed to define a specific memory limit to prevent uncontrolled resource consumption. In Redis, this is managed by the maxmemory directive. Kubernetes ConfigMaps are the ideal mechanism for injecting such configuration data into a container.

A ConfigMap named my-redis-config was created, containing the Redis configuration data under the key redis-config.

configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-redis-config
data:
  redis-config: |
    maxmemory 2mb

This ConfigMap was applied to the cluster:

kubectl apply -f configmap.yaml
configmap/my-redis-config created

Step 2: Defining the Redis Deployment

The core of the solution is the Deployment manifest, which specifies the application's desired state, including the image, resource requests, and how configuration and data volumes are handled.

Key Deployment Parameters:

Parameter Value Purpose
Name redis-deployment Standard naming convention.
Image redis:alpine Uses the lightweight Redis Alpine image.
Replicas 1 Deploys a single instance for initial testing.
CPU Request 1 Guarantees 1 full CPU core for the Redis container, ensuring high performance for cache operations.
Container Port 6379 Standard Redis port for communication.

Volume Strategy for Redis

The deployment utilizes two ephemeral volumes crucial for Redis operation in a testing environment:

EmptyDir Volume (data):

  • Purpose: Provides temporary storage for Redis's dump file (if persistence were enabled) or other scratch data.
  • Mount Path: /redis-master-data
  • Nature: Data is destroyed when the Pod terminates, aligning with the temporary nature of this initial test deployment.

ConfigMap Volume (redis-config):

  • Purpose: Mounts the my-redis-config ConfigMap so the container can access the configuration file.
  • Mount Path: /redis-master
  • Usage: The Redis server command is explicitly told to use this mounted configuration file.

deployment.yaml (Simplified Manifest)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    # ... (metadata)
    spec:
      volumes:
        - name: data
          emptyDir: {}
        - name: redis-config
          configMap:
            name: my-redis-config
      containers:
        - name: redis-container
          image: redis:alpine
          # Crucial: Instructs Redis to start with the custom config file
          command: ["redis-server"]
          args: ["/redis-master/redis-config"]
          ports:
            - containerPort: 6379
          resources:
            requests:
              cpu: "1"
          volumeMounts:
            - name: data
              mountPath: /redis-master-data
            - name: redis-config
              mountPath: /redis-master

The deployment was then applied:

thor@jumphost ~$ kubectl apply -f deployment.yaml
deployment.apps/redis-deployment created

Step 3: Verification and Conclusion

The final step confirmed that the new caching utility was operational and ready for integration testing.

thor@jumphost ~$ kubectl get deployment redis-deployment
NAME               READY   UP-TO-DATE   AVAILABLE   AGE
redis-deployment   1/1     1            1           21s

The output shows that the redis-deployment is fully available (1/1 Ready, 1 Available), confirming that the Redis container is running correctly, utilizing the requested CPU resources, and applying the custom maxmemory 2mb configuration.


This content originally appeared on DEV Community and was authored by Wycliffe A. Onyango


Print Share Comment Cite Upload Translate Updates
APA

Wycliffe A. Onyango | Sciencx (2025-10-07T08:11:28+00:00) 100 Days of DevOps: Day 65. Retrieved from https://www.scien.cx/2025/10/07/100-days-of-devops-day-65/

MLA
" » 100 Days of DevOps: Day 65." Wycliffe A. Onyango | Sciencx - Tuesday October 7, 2025, https://www.scien.cx/2025/10/07/100-days-of-devops-day-65/
HARVARD
Wycliffe A. Onyango | Sciencx Tuesday October 7, 2025 » 100 Days of DevOps: Day 65., viewed ,<https://www.scien.cx/2025/10/07/100-days-of-devops-day-65/>
VANCOUVER
Wycliffe A. Onyango | Sciencx - » 100 Days of DevOps: Day 65. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/10/07/100-days-of-devops-day-65/
CHICAGO
" » 100 Days of DevOps: Day 65." Wycliffe A. Onyango | Sciencx - Accessed . https://www.scien.cx/2025/10/07/100-days-of-devops-day-65/
IEEE
" » 100 Days of DevOps: Day 65." Wycliffe A. Onyango | Sciencx [Online]. Available: https://www.scien.cx/2025/10/07/100-days-of-devops-day-65/. [Accessed: ]
rf:citation
» 100 Days of DevOps: Day 65 | Wycliffe A. Onyango | Sciencx | https://www.scien.cx/2025/10/07/100-days-of-devops-day-65/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.