Skip to content

Instantly share code, notes, and snippets.

@stand-sure
Created May 3, 2024 14:35
Show Gist options
  • Save stand-sure/39bc1f2d7aacd07906deda27df765bcc to your computer and use it in GitHub Desktop.
Save stand-sure/39bc1f2d7aacd07906deda27df765bcc to your computer and use it in GitHub Desktop.
How to spin up a redis cli troubleshooting pod

This is for troubleshooting/fixing redis that is already running or failing to start.

Scheduling the pod on the same node

This is necessary because the PVC is RW once

  affinity:
    podAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        - topologyKey: kubernetes.io/hostname
          labelSelector:
            matchLabels:
              statefulset.kubernetes.io/pod-name: argo-cd-redis-master-0

Volume

The name of the claim needs to match that of the running pod

Commands

# enter the pod
k exec -it redis-cli -- bash

# backup problem file
# names will vary
cp appendonly.aof.63009.incr.aof appendonly.aof.63009.incr.aofbackup

redis-check-aof appendonly.aof.63009.incr.aof

redis-check-aof --fix appendonly.aof.63009.incr.aof

diff appendonly.aof.63009.incr.aof appendonly.aof.63009.incr.aofbackup
apiVersion: v1
kind: Pod
metadata:
name: redis-cli
namespace: argocd
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: kubernetes.io/hostname
labelSelector:
matchLabels:
statefulset.kubernetes.io/pod-name: argo-cd-redis-master-0
containers:
- name: redis-cli
image: docker.io/bitnami/redis:7.0.10-debian-11-r3
command:
- sleep
- Inf
volumeMounts:
- mountPath: /data
name: redis-data
volumes:
- name: redis-data
persistentVolumeClaim:
claimName: redis-data-argo-cd-redis-master-0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment