Tag Archives: deploy

How to deploy a pod to host web application in kubernets

Deploy a basic NGINX web server as a Kubernetes Pod and check if it’s running correctly.

Step 1: Create the YAML Manifest for the Pod

 -- create a new yaml file using editor 
 nano nginx-pod.yaml

 -- add following in file:
 apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
    - name: nginx
      image: nginx:latest
      imagePullPolicy: Never
      ports:
        - containerPort: 80

 

Explain:

  • apiVersion and kind: This tells us that we are creating a Pod using the main v1 API.
  • metadata.name: We name our Pod nginx for easy reference later.
  • spec.containers: This section specifies which container will run. Here, we are using the official nginx:latest image.
  • imagePullPolicy: Never: This instructs Kubernetes not to download the image from a registry, which is useful since our setup is offline.
  • ports.containerPort: 80: The NGINX container operates on port 80, the typical port for web traffic.

Ensure the Image Is Available in Minikube

To ensure the nginx:latest image is ready in Minikube, run this command:

-- For load the image:
minikube image load nginx:latest

Apply the YAML Manifest

To apply your Pod settings to the cluster, run this command:

kubectl apply -f nginx-pod.yaml
pod/nginx created

Note: The kubectl apply command sends your YAML file to Kubernetes, which creates the Pod as you set it up. If you change the YAML later, just run kubectl apply again to update the Pod without starting over.

Verify the Pod is Running

To check your Pod’s status, you need to run the following command:

kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 2m1s

kubectl get pods shows all the Pods in your current namespace. Look for a Pod called nginx and check if its STATUS is Running. If it says Pending, just wait two minutes because it’s still starting. If your Pod isn’t running, don’t worry! Check your YAML for mistakes and use kubectl describe pod nginx for more details. You’ll be fixing issues like a pro soon!

kubectl describe Pod nginx
Output:
Name: nginx
Namespace: default
Priority: 0
Service Account: default
Node: minikube/192.168.0.5
Start Time: Thu, 18 Jun 2026 12:57:10 +0000
Labels:
Annotations:
Status: Running
IP: 10.244.0.3
IPs:
IP: 10.244.0.3
Containers:
nginx:
Container ID: docker://5ca8169a69362f1f81d9a7e26e009b1804d3cb062e123b5213ec3b95fcd9f86f
Image: nginx:latest
Image ID: docker://sha256:eaf6f386053efdf0ad30236a394b4460e3669006afc9eb1220ae2047f330cc9c
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Thu, 18 Jun 2026 12:57:11 +0000
Ready: True
Restart Count: 0
Environment:
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-7zrnr (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-7zrnr:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional:
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors:
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 3m44s default-scheduler Successfully assigned default/nginx to minikube
Normal Pulled 3m43s kubelet Container image "nginx:latest" already present on machine
Normal Created 3m43s kubelet Created container nginx
Normal Started 3m43s kubelet Started container nginx

Test the Web Server Locally

Your Pod is running in the cluster, which keeps it separate from your environment. To access it directly, you need to temporarily link a local port to the Pod’s port.

To do this, run this command:

    kubectl port-forward pod/nginx 8080:80
    kubectl port-forward pod/nginx 8080:80 & -- use & for run in background

    Test on the browser window: using URL localhost:8080