Kubernetes

Getting Started with Kubernetes: A Beginner's Guide to Container Orchestration

Learn the core concepts of Kubernetes including Pods, Services, Deployments, and how to get started with K8s in your development environment.

What is Kubernetes?

Kubernetes (K8s) is an open-source container orchestration platform for automating the deployment, scaling, and management of containerized applications. Originally designed by Google, it is now maintained by the Cloud Native Computing Foundation (CNCF).

Core Concepts

Pod

A Pod is the smallest deployable unit in Kubernetes. A Pod can contain one or more containers that share network and storage resources.

apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
spec:
  containers:
    - name: nginx
      image: nginx:1.25
      ports:
        - containerPort: 80

Service

A Service provides a stable network endpoint for a set of Pods. Even when Pods are recreated, the Service IP remains the same.

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
    - port: 80
      targetPort: 80
  type: ClusterIP

Deployment

A Deployment manages Pods and ReplicaSets declaratively. It supports rolling updates and rollbacks.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.25
          ports:
            - containerPort: 80

Installing Kubernetes Locally

For local development, consider these tools:

  • minikube - Runs a single-node K8s cluster locally
  • kind - Runs K8s using Docker containers as nodes
  • k3s - Lightweight Kubernetes distribution

Quick Start with minikube

# Install minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

# Start the cluster
minikube start

# Verify installation
kubectl get nodes

Essential kubectl Commands

CommandDescription
kubectl get podsList all Pods
kubectl get servicesList all Services
kubectl describe pod <name>View Pod details
kubectl logs <pod-name>View Pod logs
kubectl apply -f <file>Apply a config file
kubectl delete -f <file>Delete resources

Summary

Kubernetes is the foundation of modern cloud-native applications. Once you understand these core concepts, you can start building scalable, highly available containerized applications.