πŸš€ 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! 🐳✨

Leave a Reply

Your email address will not be published. Required fields are marked *