← Back to Kubernetes Mastery
Basic14 min read

Kubernetes Basics

Learn Kubernetes architecture, core components, cluster setup, and kubectl — the foundation for container orchestration at scale.

Why Kubernetes?

Kubernetes (K8s) automates deploying, scaling, and managing containerized applications across clusters of machines. It handles scheduling, self-healing, load balancing, and rolling updates — problems that become critical at scale.

Docker runs containers on one host. Kubernetes orchestrates containers across many hosts, ensuring desired state: if a container crashes, K8s replaces it. If traffic increases, K8s scales replicas.

  • K8s is platform-agnostic — runs on cloud, on-prem, and local
  • The API server is the central control point for all operations
  • Declarative configuration: describe desired state, K8s reconciles
# Verify cluster connection
kubectl cluster-info
kubectl get nodes
kubectl get namespaces

Architecture Overview

A cluster has control plane nodes and worker nodes. The control plane includes the API server (entry point), etcd (state store), scheduler (pod placement), and controller manager (reconciliation loops). Worker nodes run kubelet (agent), kube-proxy (networking), and container runtime.

You interact with the API server via kubectl. It never talks to nodes directly — all operations go through the control plane.

# Control plane components
# - kube-apiserver: REST API frontend
# - etcd: distributed key-value store
# - kube-scheduler: assigns pods to nodes
# - kube-controller-manager: runs control loops

# Worker node components
# - kubelet: ensures containers run in pods
# - kube-proxy: network rules and load balancing
# - container runtime: containerd or CRI-O

kubectl Essentials

kubectl is the CLI for Kubernetes. get retrieves resources, describe shows details, apply creates/updates from YAML, delete removes resources, and logs streams pod output.

Use -n namespace for namespace-scoped commands. -o wide, -o yaml, and -o json control output format. --dry-run=client -o yaml generates manifests without applying.

kubectl get pods -n default
kubectl describe pod my-pod
kubectl apply -f deployment.yaml
kubectl logs -f pod/my-pod
kubectl exec -it my-pod -- sh
kubectl delete -f deployment.yaml

Local Development Clusters

Run Kubernetes locally with minikube, kind (Kubernetes in Docker), or Docker Desktop built-in cluster. These single-node clusters are perfect for learning and development.

kind creates clusters inside Docker containers — fast to create and destroy. minikube supports more driver options including VM-based isolation.

# kind
kind create cluster --name dev
kubectl cluster-info --context kind-dev
kind delete cluster --name dev

# minikube
minikube start --cpus 4 --memory 8192
minikube dashboard
minikube stop

Namespaces and Organization

Namespaces partition cluster resources between teams, environments, or applications. Default namespaces: default, kube-system (system components), kube-public, and kube-node-lease.

Use namespaces to isolate dev, staging, and production on shared clusters. Resource quotas and network policies can be scoped per namespace.

kubectl create namespace staging
kubectl get all -n staging
kubectl config set-context --current --namespace=staging

# All resources in a namespace
kubectl get pods,svc,deploy -n staging

Get In Touch


Ready to discuss your next project? Drop me a message.