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 technology, it provides robust infrastructure for managing Docker containers across multiple hosts.
Key Concepts
Container Orchestration
Container orchestration enables automated management of containerized applications, solving complex deployment challenges in distributed systems.
graph TD
A[Docker Containers] --> B[Kubernetes Cluster]
B --> C[Automated Deployment]
B --> D[Scaling]
B --> E[Self-Healing]
Core Components
Component |
Description |
Nodes |
Physical/Virtual machines running containers |
Pods |
Smallest deployable units in Kubernetes |
Clusters |
Group of nodes managed together |
Services |
Network configuration for pod communication |
Installation on Ubuntu 22.04
## Update system packages
sudo apt update
## Install Docker
sudo apt install docker.io
## Install Kubernetes components
sudo apt install kubeadm kubelet kubectl
## Initialize Kubernetes cluster
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
Basic Deployment Example
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:latest
ports:
- containerPort: 80
This example demonstrates a simple Nginx deployment with three replicas, showcasing Kubernetes' ability to manage containerized applications efficiently.