Skip to content

Redis Deployment

Note

Be sure to change the Redis password.

Introduction

Deployment Method Kubernetes container deployment
Redis Version 6.0.20
Deployment Prerequisites Kubernetes has been deployed
Kubernetes Storage has been deployed

Default Deployment Configuration Information

Default Address redis.middleware
Default Port 6379
Default Password viFRKZiZkoPmXnyF

Installation

Save redis.yaml and deploy.

redis.yaml (Click to open)
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: redis-config
  namespace: middleware
data:
  redis.conf: |
    requirepass viFRKZiZkoPmXnyF
    appendonly yes
    timeout 300

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis
  namespace: middleware
  labels:
    app: redis
spec:
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
        - command:
            - redis-server
            - /usr/local/etc/redis/redis.conf
          name: redis
          image: pubrepo.guance.com/googleimages/redis:6.0.20
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 6379
              name: redis-port
          volumeMounts:
            - name: data
              mountPath: /data
            - name: config
              mountPath: /usr/local/etc/redis
          resources:
            limits:
              cpu: '4'
              memory: 4Gi
            requests:
              cpu: 100m
              memory: 512Mi            
      volumes:
        - name: data
          emptyDir: {}
        - name: config
          configMap:
            name: redis-config
---
apiVersion: v1
kind: Service
metadata:
  name: redis
  namespace: middleware
spec:
  selector:
    app: redis
  type: NodePort
  ports:
    - name: redis-port
      protocol: TCP
      port: 6379
      targetPort: redis-port

Execute the following commands to install:

kubectl create namespace middleware
kubectl apply -f redis.yaml

Verify Deployment

  • Check pod status
kubectl get pods -n middleware | grep redis

How to Uninstall

kubectl delete -f redis.yaml

Feedback

Is this page helpful? ×