Learning Kubernetes From Scratch (Part 2) – Pods
By Newt / June 26, 2025 / No Comments / Kubernetes
π Let's Get Started with Pods! π
Welcome to this quick guide on deploying your first Kubernetes pod using Minikube. We'll walk through setting up your environment, creating a pod configuration, deploying it, and verifying everything works smoothly. Ready to dive in? Letβs go! βοΈπ³
1. Environment Setup βοΈ
First, we started our Minikube cluster (Make sure you've set up Docker Desktop π³ on the machine before this tutorial, and it's running):
minikube start --driver=docker --cpus=2 --memory=4096mb (recommended to run this amount of resources)
# Check kubectl context π
kubectl config current-context
# Check cluster info π
kubectl cluster-info
2. Pod Configuration π
I used the following YAML configuration:
apiVersion: v1 kind: Pod metadata: name: nginx-pod labels: app: web tier: frontend spec: containers: - name: nginx image: nginx:1.14 ports: - containerPort: 80 resources: requests: memory: "64Mi" cpu: "250m" limits: memory: "128Mi" cpu: "500m"
Save YAML file as "01-simple-pod.yaml" in the 'exercises/1-basics/pods folder'.
3. Pod Deployment and Verification π
# Deploy the pod π§©
kubectl apply -f exercises/1-basics/pods/01-simple-pod.yaml
# Verify pod status β
kubectl get pods
# Get detailed pod information π
kubectl describe pod nginx-pod
# View pod logs π
kubectl logs nginx-pod
# Set up port forwarding π
kubectl port-forward nginx-pod 8080:80
4. Understanding the Components π§©
- Pod Configuration:
apiVersion: v1
- Specifies Kubernetes API version π οΈkind: Pod
- Defines resource type π¦metadata
- Contains pod name and labels π·οΈspec
- Defines pod behavior and containers βοΈ
- Resource Limits:
- Requests (minimum): 250m CPU, 64Mi memory β‘
- Limits (maximum): 500m CPU, 128Mi memory π§
- Networking:
- Container Port: 80 (nginx default) π
- Port Forward: localhost:8080 β pod:80 π
5. Current Status π
The pod is running with:
- Name: nginx-pod π±βπ€
- Status: Running π’
- Accessible via: http://localhost:8080 π
Common Commands Reference π
# Get pod status π
kubectl get pods
# Get detailed pod info π
kubectl describe pod nginx-pod
# Delete pod ποΈ
kubectl delete pod nginx-pod
# Get pod logs π
kubectl logs nginx-pod
# Execute command in pod π₯οΈ
kubectl exec -it nginx-pod -- /bin/bash
Have a look, explore the pod and what's in there. Using Linux commands ls
(to view the current directory contents) and cd
(to traverse the directories) π§.
To STOP π
Great job! Youβve successfully deployed and explored your first pod. Remember to stop and clean up your Minikube cluster to free resources when youβre done:
# Stop minikube π
minikube stop
# Delete minikube cluster π§Ή
minikube delete
You're now ready to move onto the next tutorial! Happy Kubernetes-ing! π³β¨