# TheArchitectureRoom — Kubernetes examples

The example manifests from the Kubernetes journeys on [thearchitectureroom.tech](https://thearchitectureroom.tech).
Run them and watch the concepts (pods, deployments, self-healing) happen for real.

## No install needed — try it in your browser

Open a free Kubernetes playground (a real cluster, ~zero setup):

- **Killercoda** — https://killercoda.com/playgrounds/scenario/kubernetes
- or **Play with Kubernetes** — https://labs.play-with-k8s.com

Paste the manifests below and go.

## Run it locally

You need a cluster and `kubectl`. The easiest local cluster is **kind** or **minikube**:

```bash
# create a local cluster (pick one)
kind create cluster           # https://kind.sigs.k8s.io
minikube start                # https://minikube.sigs.k8s.io

# clone this repo, then:
kubectl apply -f pod.yaml
kubectl get pods
```

## Walk through the ideas

**1. A single pod**

```bash
kubectl apply -f pod.yaml
kubectl get pods
kubectl describe pod web
kubectl logs web
```

**2. A Deployment (the blueprint) — desired state = 3 replicas**

```bash
kubectl apply -f deployment.yaml
kubectl get pods            # three pods appear
kubectl get deploy,rs,pods  # Deployment -> ReplicaSet -> Pods
```

**3. See self-healing for yourself**

```bash
# delete one pod and watch Kubernetes rebuild it to keep 3 alive
kubectl delete pod -l app=web --field-selector status.phase=Running | head -1
kubectl get pods -w
```

**4. Scale up / down (declarative)**

```bash
kubectl scale deployment/web --replicas=5
kubectl get pods
```

**5. Reach it with a Service (a stable front desk)**

```bash
kubectl apply -f service.yaml
kubectl get svc backend        # a stable IP + name that never changes
# from inside the cluster, other pods reach it as: http://backend
```

**6. Route traffic with Ingress (one front door for many services)**

```bash
# needs an Ingress Controller in the cluster (e.g. ingress-nginx)
kubectl apply -f ingress.yaml
kubectl get ingress web
```

**7. Give data a home that outlives the pod (a PersistentVolumeClaim)**

```bash
kubectl apply -f pvc.yaml
kubectl get pvc data           # most clusters auto-provision a real disk (Bound)
# mount it in a pod via spec.volumes -> persistentVolumeClaim: { claimName: data }
# then: delete the pod, start a new one mounting the same claim -> data is still there
```

**8. Lock it down (least privilege)**

```bash
# RBAC — a read-only role for a user
kubectl apply -f rbac.yaml
kubectl auth can-i list pods --as=dev     # yes
kubectl auth can-i delete pods --as=dev   # no

# NetworkPolicy — only app=api pods may reach app=db pods
# (needs a policy-enforcing CNI like Calico or Cilium)
kubectl apply -f networkpolicy.yaml
```

**9. Clean up**

```bash
kubectl delete -f deployment.yaml
kubectl delete -f pod.yaml
```

---

More chapters (traffic, storage, security, scaling, production) are being added on the site — each with its own runnable examples.
