Running a Simple Web App: Deploying Nginx in Kubernetes
Learn how to deploy an Nginx container as a Pod in Kubernetes. We'll cover inspecting status, verifying service, and mastering basic Pod lifecycle management.

Previously in this course, we covered The Pod Lifecycle and discussed how to define and apply configurations. Now that you understand the mechanics of the Pod, it’s time to move from theoretical manifests to a functional application. In this lesson, we will deploy an Nginx container—the industry standard for a lightweight web server—and verify that it is actually serving content.
Why Nginx?
Nginx is the "Hello World" of the container world. It is small, starts nearly instantaneously, and provides clear feedback when it's working. By using Nginx, we can isolate the process of verifying a Kubernetes Pod from the complexities of application-specific dependencies like database connections or environment variables.
Deploying Your First Web App
To get started, we will create a simple manifest. If you have been following our project, you likely have a directory for your YAML files. Create a file named nginx-pod.yaml:
YAMLapiVersion: v1 kind: Pod metadata: name: nginx-web-server labels: app: web-server spec: containers: - name: nginx-container image: nginx:alpine ports: - containerPort: 80
Apply this to your cluster using the command we mastered in Applying Manifests to the Cluster:
Bashkubectl apply -f nginx-pod.yaml
Inspecting Pod Details
Once applied, the Pod enters the Pending state while the container image is pulled from the registry, then moves to Running. To inspect the current state of your web app, use the describe command:
Bashkubectl describe pod nginx-web-server
Pay close attention to the Events section at the bottom of the output. This is your primary diagnostic tool. If the Pod is stuck, you will see messages here like Pulling image or Failed. If everything is healthy, you will see Started container nginx-container.
Verifying the Container
Just because a Pod is "Running" doesn't necessarily mean the web server is ready to handle requests. To confirm the server is responsive, we need to peek inside the container. We can use kubectl exec to run a command inside the running Pod:
Bash# This checks if the Nginx process is actually listening on port 80 kubectl exec nginx-web-server -- curl -I localhost
If you receive an HTTP/1.1 200 OK response, congratulations—your first web application is successfully serving traffic within the cluster.
Common Pitfalls
When deploying your first web app, you will likely encounter these three common issues:
- Image Pull Errors: If you mistype the image name (e.g.,
nginxx), the Pod will sit inImagePullBackOff. Always double-check your image tags. - Port Mismatch: If your application is configured to listen on port 8080 but your manifest says
containerPort: 80, the container will run, but you won't be able to reach your service later. - Namespace Confusion: If you run
kubectl get podsand don't see your Pod, ensure you are in the correct namespace. Remember our lesson on Understanding Namespaces.
Hands-On Exercise
- Create the
nginx-pod.yamlfile provided above. - Deploy it and wait for the status to reach
Running. - Use
kubectl logs nginx-web-serverto view the server startup logs. - Delete the Pod using
kubectl delete pod nginx-web-serverand observe how the cluster removes the resource.
Frequently Asked Questions (FAQ)
Q: Do I need to install Nginx on my host machine? A: No. The container image contains everything Nginx needs to run. The host machine is only responsible for running the container runtime (like containerd or Docker).
Q: How do I access this from my browser? A: Currently, you can't. Pods are isolated within the cluster network. We will cover how to expose this to your browser in upcoming lessons on Services and Port Forwarding.
Q: What does the 'alpine' tag mean? A: It refers to Alpine Linux, a security-oriented, lightweight Linux distribution. Using it keeps your image sizes small, which speeds up deployment times.
Recap
We have successfully deployed an Nginx container, inspected its status using describe, and verified its internal health using exec. You now have a working web app running in your cluster, providing a stable foundation for the networking lessons that follow.
Up next: We will learn how to organize our resources effectively by adding Labels and Selectors to our Pods.
Work with me

VPS Server Setup, Deployment & Hardening
Get your app live on a fast, secure server — properly configured, hardened, and deployment-ready. No more wrestling with the command line.

Next.js Full-Stack Web App Development
A fast, SEO-ready full-stack web app built with Next.js 16 — from idea to deployed product, by an engineer who ships to production.


