Kubernetes Level 02 Day 10: Troubleshoot Deployment Issues¶
This document outlines the troubleshooting and resolution process for Kubernetes Level 02 Day 10. An existing Redis deployment was broken after manual changes. By analyzing describe logs, two primary configuration errors were identified and corrected.
Table of Contents¶
- Kubernetes Level 02 Day 10: Troubleshoot Deployment Issues
- Table of Contents
- Task Overview
- Troubleshooting Process
- Step-by-Step Solution
- Deep Dive: Common Deployment Errors
Task Overview¶
Objective: Resolve the failure of the redis-deployment to ensure the Redis app returns to a Running state.
- Deployment Name:
redis-deployment - Current State: 0/1 Available, Pod stuck in
ContainerCreating. - Root Causes Found:
- Incorrect ConfigMap name reference (
redis-cofigvsredis-config). - Incorrect container image tag (
redis:alpinvsredis:alpine).
- Incorrect ConfigMap name reference (
Troubleshooting Process¶
1. Identify the Resource Issues¶
We start by checking the status of the deployment.
kubectl get deployments
AVAILABLE is 0.
Next, we describe the deployment to see the container specifications.
kubectl describe deployment redis-deployment
redis:alpin.
* The Volume named config is looking for a ConfigMap named redis-cofig.
2. Analyze Pod Failure¶
We look at the pod events to see why it won't start.
kubectl describe pod <redis-pod-name>
Warning FailedMount ... MountVolume.SetUp failed for volume "config" : configmap "redis-cofig" not found
Step-by-Step Solution¶
To resolve these issues, we need to edit the deployment configuration.
Command:
kubectl edit deployment redis-deployment
1. Fix ConfigMap Typo¶
In the editor, scroll down to the volumes: section at the bottom.
Change:
volumes:
- name: config
configMap:
name: redis-cofig # Change this
volumes:
- name: config
configMap:
name: redis-config # Fixed typo
2. Fix Image Tag Typo¶
In the same editor, locate the containers: section.
Change:
spec:
containers:
- name: redis-container
image: redis:alpin # Change this
spec:
containers:
- name: redis-container
image: redis:alpine # Fixed typo
Save and exit the editor (:wq).
3. Verification¶
Verify that the deployment triggers a new rollout and the pod starts successfully.
kubectl rollout status deployment redis-deployment
kubectl get pods
Running and Ready 1/1.
Deep Dive: Common Deployment Errors¶
Missing ConfigMaps/Secrets¶
If a Pod references a ConfigMap or Secret that does not exist, it will stay in the ContainerCreating or Pending state. Kubernetes will keep trying to find the resource, as seen in the "FailedMount" events.
Image Tag Errors¶
Docker/Container images are case-sensitive and spelling-sensitive.
* redis:alpin (Incorrect)
* redis:alpine (Correct)
If an image tag is wrong, the pod will usually enter ImagePullBackOff. However, because the ConfigMap was also missing in this task, the pod was stuck at the "Mounting Volumes" stage before it even attempted to pull the image.
Idempotency and kubectl edit¶
kubectl edit allows for live debugging. When you save your changes, Kubernetes notices the difference between the "desired state" (your new YAML) and the "current state". It then terminates the old, broken pod and starts a new one with your fixes.