# Kubernetes and Terraform: do you need them?

Two names you often hear, and which your AI assistant sometimes suggests. They’re powerful, but too resource-intensive for most small and medium-sized apps. This guide will help you choose.

## What is Kubernetes?

**Kubernetes** (often referred to as “K8s”) runs and manages many containers across multiple servers. It restarts containers if they crash, distributes traffic and automatically scales up and down.

Terms you’ll come across:

| Term | Meaning |
|---|---|
| Pod | The smallest unit: one or more containers together |
| Deployment | Ensures that there are always X copies of your pod running |
| Service | A fixed address where you can collect your pods |
| Ingress | Inbound traffic (domains, HTTPS) |
| Node | A server in the cluster |
| Namespace | A separate space within the cluster |
| ConfigMap / Secret | Settings / secrets for your pods |

## What is Terraform?

**Terraform** describes your infrastructure (servers, databases, DNS, storage) in code files. This allows you to rebuild a complete environment and see every change reflected in Git. This is known as **Infrastructure as Code**.

## Do you need it?

| Situation | Advice |
|---|---|
| One app, one database, up to thousands of users | **No.** A managed platform or a VPS with Docker is cheaper and simpler (see *Putting your Laravel app online*). |
| Multiple apps or services, a team with DevOps experience | Perhaps. Start with a managed container platform, and only switch once you’ve reached your limits. |
| Many services, strict availability requirements, multiple environments | Yes, and preferably **managed Kubernetes** (the cloud provider manages the cluster). |
| Your infrastructure consists of many separate cloud components that you often have to set up from scratch | Terraform is useful in this situation, even without Kubernetes. |

Is your AI assistant suggesting Kubernetes for a small app? If so, ask for clarification: *"Why is this necessary, and what is the simplest alternative?"*

## If you’re working with Kubernetes anyway

```bash
kubectl get pods                          # wat draait er?
kubectl describe pod <naam>               # details en fouten
kubectl logs -f <pod>                     # logs volgen
kubectl apply -f deployment.yaml          # wijziging toepassen
kubectl rollout status deployment/app     # voortgang van een update
kubectl rollout undo deployment/app       # vorige versie terug
```

First, use `kubectl apply --dry-run=client -f …` to see what happens. Be careful when using `kubectl delete`.

## If you’re using Terraform anyway

Always follow this order:

```bash
terraform init
terraform fmt
terraform validate
terraform plan -out=tfplan     # bekijk wat er verandert
terraform apply tfplan
```

When using `plan`, pay particular attention to lines containing `-` (delete) and `-/+` (replace). Is a database being deleted? Stop and check. Store the **state** in a secure remote backend and never in Git. The 

## Need help?

Not sure which architecture is right for your app? At **Bespoke Software and Web Applications**, I choose the simplest architecture that ensures your app runs reliably and can be expanded later on.

## Skills

- [Kubernetes Manifest Generator] (/nl/skills/k8s-manifest-generator)
- [Helm Chart Scaffolding] (/nl/skills/helm-chart-scaffolding)
- [GitOps Workflow] (/nl/skills/gitops-workflow)
- [Kubernetes Security Policies] (/nl/skills/k8s-security-policies)
- [Terraform safe workflow] (/nl/skills/terraform-safe-workflow)
- [Terraform Module Library] (/nl/skills/terraform-module-library)
- [Multi-Cloud Architecture] (/nl/skills/multi-cloud-architecture)
- [Cloud Cost Optimization] (/nl/skills/cost-optimization)

## Related services

- [Maatwerk software en webapplicaties] (/nl/services#service-03)

