Kubernetes Troubleshooting for Application Developers

Introduction

Course Introduction

Welcome to Kubernetes Troubleshooting for Application Developers! I'm Nourhan Khaled, your instructor for this course.

Learning Kubernetes from tutorials is one thing, but deploying a production application introduces a unique set of challenges that often feel like you're constantly putting out fires. This lesson bridges the gap between theory and practice—the very course I wish I had during those frustrating debugging sessions.

Prerequisites

Ensure you have a basic understanding of Kubernetes resources such as pods, deployments, services, storage, and network policies before you begin.

Course Overview

We start with a concise refresher on essential kubectl commands for troubleshooting common Kubernetes errors. Then, the course dives into real-world scenarios that mirror the challenges you may face in production environments.

For instance, consider this output when listing namespaces:

NAME                             STATUS    AGE
default                          Active    27m
dev                              Active    26m
ingress-nginx                    Active    25m
kube-flannel                     Active    26m
kube-node-lease                  Active    26m
kube-public                      Active    26m
kube-system                      Active    27m
kubernetes-dashboard             Active    25m
monitoring                       Active    25m
prod                             Active    25m
staging                          Active    25m
test                             Active    26m

Next, you may check your deployments with a command similar to:

controlplane ~ ➜  k get deployments

Hands-On Troubleshooting

This course stands out because you'll troubleshoot and resolve issues in real time—exactly as I do in my day-to-day work. Consider the following YAML configuration for a pod in the production namespace:

apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"labels":{"app":"api"},"name":"api","namespace":"production"},"spec":{"containers":[{"image":"docker.io/library/nginx:alpine","name":"api"}]}}
  creationTimestamp: "2024-05-06T22:50:59Z"
  labels:
    app: api
    name: api
  namespace: production
  resourceVersion: "71898"
  uid: 823d9b4c-5ed8-44c9-9c3c-847f5286810c
spec:
  containers:
    - image: docker.io/library/nginx:alpine
      imagePullPolicy: IfNotPresent
      name: api
      resources: {}
      terminationMessagePath: /dev/termination-log
      volumeMounts:
        - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
          name: kube-api-access-6sxl
          readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: node01
  preemptionPolicy: PreemptLowerPriority
  priority: 0

For deeper diagnosis, you might issue commands like these:

k get -n production pod notifications -o yaml > not.yaml
vim not.yaml

Real-World Scenarios

Throughout the lesson, you will explore a range of troubleshooting challenges including pod configuration errors, deployment issues, container settings, and networking challenges such as service issues, network policies, and ingress problems. Additionally, you will learn how to diagnose RBAC and storage-related issues.

Here's an example output from one of our real-world troubleshooting scenarios:

context: kubernetes-admin@kubernetes
Cluster: kubernetes
User: kubernetes-admin
K9s Rev: v0.32.4
K8s Rev: v1.29.0
CPU: 0%
MEM: 0%

NAME            PF   READY   STATUS           RESTARTS   CPU   MEM   %CPU/R   %MEM/R   NODE        AGE
analyzer        -    0/1     ImagePullBackOff 0          0     0     n/a      n/a      10.244.1.4  10m
api             -    1/1     Running          0          0     16    n/a      n/a      10.244.1.2  10m
notifications   -    1/1     Running          0          0     70    n/a      n/a      10.244.1.6  8m51s
portal          -    0/1     ImagePullBackOff 0          0     0     n/a      n/a      10.244.1.3  10m

Important

Always test changes in a controlled environment before applying fixes to production. Insufficient testing can lead to unexpected disruptions.

Hands-On Labs

Like all KodeKloud courses, this lesson features multiple hands-on labs. These browser-based labs enable you to immediately apply the troubleshooting techniques you learn, ensuring you gain practical, real-world experience.

If you're ready for a challenge, enroll now and start mastering Kubernetes troubleshooting!

The image shows a list of Kubernetes troubleshooting scenarios on the left, and a person speaking on the right, sitting in front of a plant.

Watch Video

Watch video content