Operating Kubernetes Deployments

Introduction: Managing Your Running Application

Deploying an application is just the beginning. Once your application is running in Kubernetes, you need to know how to manage it, monitor its health, troubleshoot issues, and make changes as requirements evolve. This lesson focuses on the essential operations you'll perform regularly, forming the core toolkit for any Kubernetes practitioner.

You'll learn how to check the status of your deployments and pods, view application logs, scale your application up or down, update it to new versions, and restart it when necessary. These commands allow you to declare your desired state and let Kubernetes handle the complex orchestration. The manifest file represents your goal, but these operational commands give you real-time visibility and control over the actual state of your cluster, which is critical for running production applications. We'll continue working with the my-web-deploy deployment from the previous lesson.

Checking Deployment and Pod Status

The first skill you need when managing Kubernetes applications is the ability to check their status. You need to know whether your deployments are healthy, how many pods are running, and whether those pods are ready to accept traffic. Kubernetes provides several commands that give you different levels of detail about your resources, and knowing which command to use in different situations is an important part of working effectively with Kubernetes.

The most basic way to check your resources is with the kubectl get command. You've seen this command before, but now you'll learn how to use it more effectively. Instead of checking deployments and pods separately, you can view them together in a single command:

kubectl get deploy,pods -n apps

This command tells kubectl to retrieve both deployments and pods from the apps namespace. The output shows you both resource types in a single view:

NAME                            READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/my-web-deploy   1/1     1            1           5m

NAME                                 READY   STATUS    RESTARTS   AGE
pod/my-web-deploy-7d4f8b9c5d-x7k2m   1/1     Running   0          5m

This combined view is useful because it shows you the relationship between the deployment and its pods. The deployment shows that it wants one replica and has one replica ready. The pod shows that it's running and has been restarted zero times. If there were any problems, you'd see them immediately in this output. For example, if the pod was crashing, you'd see a high restart count. If the pod couldn't pull the image, you'd see a status like ImagePullBackOff. This quick overview is often the first thing you check when investigating issues or verifying that changes have taken effect.

When you want more detailed information about a deployment's progress, you can use the kubectl rollout status command. This command is specifically designed to monitor deployments and show you whether a rollout is complete:

kubectl rollout status deploy/my-web-deploy -n apps

The output tells you whether the deployment has successfully rolled out:

deployment "my-web-deploy" successfully rolled out

This command is particularly useful when you're waiting for a deployment to complete after making changes. If you've just updated the image or scaled the deployment, kubectl rollout status will wait and show you progress until the rollout is complete. If something goes wrong during the rollout, this command will show you the error. The command blocks until the rollout finishes or fails, which makes it perfect for use in scripts or CI/CD pipelines where you need to wait for a deployment to complete before proceeding to the next step.

For even more detailed information about a deployment, you can use the kubectl describe command. This command shows you everything Kubernetes knows about a resource, including its configuration, current state, and recent events:

kubectl describe deploy/my-web-deploy -n apps

The output from describe is extensive and includes many sections. You'll see the deployment's selector, the pod template, the replica count, and, most importantly, the events section at the bottom. The output from describe is extensive, but a few key sections provide the most value:

Name:                   my-web-deploy
Namespace:              apps
CreationTimestamp:      Thu, 15 Jan 2026 10:30:00 -0500
Labels:                 <none>
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=my-web
Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=my-web
  Containers:
   web:
    Image:      123456789012.dkr.ecr.us-east-1.amazonaws.com/my-web-app:1.0.0
    Port:       5000/TCP
    Host Port:  0/TCP
    Limits:
      cpu:     500m
      memory:  256Mi
    Requests:
      cpu:        100m
      memory:     128Mi
    Environment:
      PORT:  5000
    Mounts:   <none>
  Volumes:    <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   my-web-deploy-7d4f8b9c5d (1/1 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  5m    deployment-controller  Scaled up replica set my-web-deploy-7d4f8b9c5d to 1

Let's break down the most important parts of this output.

  • Replicas and StrategyType: These lines show the desired number of pods and the strategy (RollingUpdate) Kubernetes will use to update them.
  • Pod Template: This section details the specification for the pods that the deployment manages, including the container image, ports, resource requests, and limits.
  • Conditions: This provides a high-level summary of the deployment's current state, such as whether it's Available and Progressing.
  • Events: This is a log of recent actions the deployment controller has taken, such as scaling a ReplicaSet up or down.

The events section is particularly valuable for troubleshooting, as it often contains clues about what went wrong. The describe command gives you the complete picture of a resource's state, which is essential when you need to understand why something isn't working as expected.

Sign up

Join the 1M+ learners on CodeSignal

Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal