LUNAROPS · OPERATIONAL UPLINK 100% UPTIME 1,247d POSTS 893 JEFF.MOON@LUNAROPS.DEV UTC --:--:--

Kubernetes Basics: Getting Started with Container Orchestration

kubernetescontainersorchestrationk8s

Kubernetes has become the standard for container orchestration. This guide covers the essential concepts you need to understand before diving in.

What is Kubernetes?

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

Core Concepts

Pods

The smallest deployable unit in Kubernetes. A pod can contain one or more containers that share storage and network.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
spec:
  containers:
  - name: nginx
    image: nginx:1.27-alpine
    ports:
    - containerPort: 80

Deployments

Manage the desired state of your pods, handling updates and rollbacks.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
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.21
        ports:
        - containerPort: 80

Services

Expose your pods to network traffic, providing stable endpoints.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
  - port: 80
    targetPort: 80
  type: ClusterIP

Essential kubectl Commands

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Get cluster info
kubectl cluster-info

# List resources
kubectl get pods
kubectl get deployments
kubectl get services

# Describe resources
kubectl describe pod nginx-pod

# Apply configuration
kubectl apply -f deployment.yaml

# View logs
kubectl logs pod-name

# Execute commands in pod
kubectl exec -it pod-name -- /bin/bash

Getting Started

  1. Install kubectl and a local cluster (minikube or kind)
  2. Create your first deployment
  3. Expose it with a service
  4. Scale up and down

Kubernetes has a steep learning curve, but mastering the basics opens doors to powerful container orchestration capabilities.

Comments