Kubernetes Basics
What is Kubernetes?
Kubernetes is an open-source container orchestration platform designed to automate deployment, scaling, and management of containerized applications. As a cloud-native platform, it provides robust infrastructure for running Docker containers efficiently across multiple computing environments.
Core Concepts and Architecture
Kubernetes operates through a complex but powerful cluster architecture with several key components:
graph TD
A[Master Node] --> B[API Server]
A --> C[Controller Manager]
A --> D[Scheduler]
A --> E[etcd Storage]
F[Worker Nodes] --> G[Kubelet]
F --> H[Container Runtime]
F --> I[Pods]
Component |
Description |
Function |
Master Node |
Cluster control plane |
Manages overall cluster state |
Worker Nodes |
Application execution environment |
Runs containerized workloads |
Pods |
Smallest deployable units |
Contains one or more containers |
Basic Kubernetes Deployment Example
Here's a simple Ubuntu 22.04 example of deploying a nginx pod:
## Install kubectl and minikube
sudo apt update
sudo apt install -y curl wget apt-transport-https
curl -LO -s
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
## Create nginx deployment
kubectl create deployment nginx-demo --image=nginx
kubectl expose deployment nginx-demo --port=80 --type=NodePort
Key Benefits of Kubernetes
Kubernetes provides critical advantages for modern software development:
- Automated container scaling
- Self-healing infrastructure
- Declarative configuration management
- Advanced networking and service discovery
Container Orchestration Workflow
sequenceDiagram
participant Dev as Developer
participant K8s as Kubernetes Cluster
participant App as Application
Dev->>K8s: Deploy Container
K8s->>App: Schedule and Run
K8s->>App: Monitor Health
App-->>K8s: Report Status