Infrastructure

Introduction to Kubernetes

Container orchestration at scale


Kubernetes (K8s) is an open-source container orchestration platform that automates deploying, scaling, and managing containerized applications. Originally designed by Google, it's now maintained by the Cloud Native Computing Foundation (CNCF).

Our managed Kubernetes offering is built on K3s — a lightweight, CNCF-certified Kubernetes distribution packaged as a single binary (under 100MB). K3s provides full Kubernetes API compatibility with built-in Traefik ingress, Flannel CNI, and embedded etcd, making it ideal for cloud VMs, bare metal, and edge deployments.

Why Kubernetes?#

Container orchestration#

Kubernetes manages containers across multiple hosts, handling scheduling, scaling, and self-healing automatically.

Declarative configuration#

Define the desired state of your application, and Kubernetes ensures the actual state matches.

Scalability#

Easily scale applications up or down based on demand, either manually or automatically.

Self-healing#

Kubernetes restarts failed containers, replaces and reschedules containers when nodes die, and kills containers that don't respond to health checks.

Core concepts#

Pods#

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

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

Deployments#

Deployments manage the desired state for Pods and ReplicaSets, enabling declarative updates.

1
apiVersion: apps/v1
2
kind: Deployment
3
metadata:
4
name: nginx-deployment
5
spec:
6
replicas: 3
7
selector:
8
matchLabels:
9
app: nginx
10
template:
11
metadata:
12
labels:
13
app: nginx
14
spec:
15
containers:
16
- name: nginx
17
image: nginx:1.24
18
ports:
19
- containerPort: 80

Services#

Services provide stable network endpoints for accessing Pods.

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

ConfigMaps and Secrets#

ConfigMaps store non-confidential configuration data, while Secrets store sensitive information.

1
apiVersion: v1
2
kind: ConfigMap
3
metadata:
4
name: app-config
5
data:
6
DATABASE_HOST: "db.example.com"
7
LOG_LEVEL: "info"

Namespaces#

Namespaces provide a way to divide cluster resources between multiple users or teams.

1
apiVersion: v1
2
kind: Namespace
3
metadata:
4
name: production

Architecture#

Control plane#

The control plane manages the overall state of the cluster:

  • API Server: The front-end for the Kubernetes control plane
  • etcd: Consistent and highly-available key-value store
  • Scheduler: Assigns Pods to nodes
  • Controller Manager: Runs controller processes

Worker nodes#

Worker nodes run your containerized applications:

  • kubelet: Ensures containers are running in Pods
  • kube-proxy: Maintains network rules
  • Container runtime: Runs containers (e.g., containerd, CRI-O)

Basic commands#

1
# Get cluster information
2
kubectl cluster-info
3
4
# List all pods
5
kubectl get pods
6
7
# Create resources from a file
8
kubectl apply -f deployment.yaml
9
10
# View logs
11
kubectl logs <pod-name>
12
13
# Execute command in a container
14
kubectl exec -it <pod-name> -- /bin/bash
15
16
# Delete resources
17
kubectl delete -f deployment.yaml

Integration with DevOps Hub#

Deploy to Kubernetes from DevOps Hub pipelines:

1
stages:
2
- name: deploy
3
jobs:
4
- name: deploy-to-k8s
5
runner: ubuntu-latest
6
steps:
7
- checkout
8
- run: |
9
kubectl apply -f k8s/
10
kubectl rollout status deployment/my-app

Next steps#