Last week, the Nautilus DevOps team deployed a redis app on Kubernetes cluster, which was working fine so far. This morning one of the team members was making some changes in this existing setup, but he made some mistakes and the app went down. We need to fix this as soon as possible. Please take a look.
The deployment name is redis-deployment. The pods are not in running state right now, so please look into the issue and fix the same.
Step 1: Identify the Issue
kubectl get deployments
kubectl get pods
kubectl describe deployment redis-deployment
Issues Found:
- Pod stuck in
ContainerCreatingstatus - Image:
redis:alpin(invalid, should beredis:alpine) - ConfigMap:
redis-conig(misspelled, should beredis-config)
Step 2: Delete the Faulty Deployment
kubectl delete deployment redis-deployment
Step 3: Create Corrected YAML
cat > redis-deployment-fixed.yaml << 'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-deployment
labels:
app: redis
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis-container
image: redis:alpine
ports:
- containerPort: 6379
resources:
requests:
cpu: 300m
volumeMounts:
- mountPath: /redis-master-data
name: data
- mountPath: /redis-master
name: config
volumes:
- name: data
emptyDir: {}
- name: config
configMap:
name: redis-config
EOF
Step 4: Apply the Corrected Deployment
kubectl apply -f redis-deployment-fixed.yaml
Step 5: Verify the Fix
kubectl get deployments
Output:
NAME READY UP-TO-DATE AVAILABLE AGE
redis-deployment 1/1 1 1 31s
kubectl get pods
Output:
NAME READY STATUS RESTARTS AGE
redis-deployment-5476b4ddd6-f7txp 1/1 Running 0 31s
Key Learnings
Common Issues and Fixes
| Issue | Symptom | Fix |
|---|---|---|
| Invalid image name | ContainerCreating |
Use correct image name and tag |
| Misspelled ConfigMap | ContainerCreating |
Match ConfigMap name exactly |
| Missing ConfigMap | ContainerCreating |
Create the ConfigMap |
| Resource limits |
Pending or CrashLoopBackOff
|
Adjust resource requests/limits |
Troubleshooting Commands
| Command | Purpose |
|---|---|
kubectl get deployments |
Check deployment status |
kubectl get pods |
Check pod status |
kubectl describe deployment <name> |
Detailed deployment info |
kubectl describe pod <name> |
Detailed pod info |
kubectl logs <pod-name> |
View pod logs |
kubectl get events |
View cluster events |
kubectl rollout status deployment <name> |
Check rollout status |
Top comments (0)