Loading

Quipoin Menu

Learn • Practice • Grow

kubernetes / Creating Pods
tutorial

Creating Pods

Creating Pods is the first step in running applications on Kubernetes. You can create Pods imperatively with kubectl run or declaratively with YAML files. This chapter covers both methods.

Method 1: Imperative with kubectl run

Quickly create a single Pod from the command line:
kubectl run my-nginx --image=nginx --restart=Never
--restart=Never ensures a Pod is created instead of a Deployment. Check it:
kubectl get pods
Delete it:
kubectl delete pod my-nginx

Method 2: Declarative with YAML

Create a YAML file (e.g., my-pod.yaml):
apiVersion: v1
kind: Pod
metadata:
name: my-nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
Apply it:
kubectl apply -f my-pod.yaml
This method is preferred because the file can be version‑controlled.

Viewing Pod Details

See pod status:
kubectl get pods -o wide
Get detailed info:
kubectl describe pod my-nginx

Port Forwarding

To access a Pod locally, you can forward a port:
kubectl port-forward pod/my-nginx 8080:80
Now open http://localhost:8080 to see Nginx.


Two Minute Drill
  • Imperative: kubectl run pod-name --image=image --restart=Never.
  • Declarative: YAML file + kubectl apply -f file.yaml.
  • View pods: kubectl get pods; details: kubectl describe pod.
  • Access pod: kubectl port-forward pod/pod-name local:container.

Need more clarification?

Drop us an email at career@quipoinfotech.com