M0-S2 — Build your lab cluster
Section titled “M0-S2 — Build your lab cluster”| Module | M0 — Start here |
| After this session you can | Stand up and verify the local evaluation cluster every later lab uses: Kubernetes, ingress, MongoDB, RabbitMQ, Redis and a mail catcher, with the chart pulled and ready. |
| Time | Facilitated: 54 min · On your own: 54 min |
| Before you start | M0-S1. Docker, kind, kubectl and helm installed. Your vendor’s evaluation pack. |
| Go deeper | Helm chart: external prerequisites |
◆ Orientation (1 min) — Why you bring your own datastores
Section titled “◆ Orientation (1 min) — Why you bring your own datastores”The Osos chart installs only Osos‘s own services. It never installs a database, a message broker or a cache: in production those are run by a database team or a managed cloud service, and the chart only receives their addresses. So before you can install anything, you need a cluster and the three datastores. In this session you build both, on your own computer.
▤ Concept (4 min) — The lab you are building
Section titled “▤ Concept (4 min) — The lab you are building”What the chart expects around it
Section titled “What the chart expects around it”| Dependency | What Osos uses it for | In production | In your lab |
|---|---|---|---|
| Kubernetes | Runs every workload the chart renders | A managed or self-run cluster | kind: a whole cluster inside one Docker container |
| Ingress controller | Receives web traffic and routes it to the platform | nginx by default (the chart creates the Ingress, not the controller) | ingress-nginx, listening on your ports 80 and 443 |
| MongoDB | Every record, definition and setting | A replica set, with authentication and TLS | One-member replica set, no authentication |
| RabbitMQ | The message bus between services | A cluster with quorum queues | One node with the management API on |
| Redis | Caches, the gateway’s lookups, background job queues | Sentinel or a managed service, with TLS | One instance with a lab password |
| Mail server | Password-reset and notification emails | Your organization’s SMTP relay | Mailpit: catches every email and shows it in a web page |
| Object storage | Uploaded files | Azure, S3-compatible or Google storage | A disk volume (set in M2-S1) |
The lab cuts corners that production never may: single copies, no TLS, no authentication on MongoDB,
and passwords such as lab-only-redis that are deliberately obvious. Every lab secret in this course
starts with lab-only so you can never mistake it for a real one.
flowchart LR
B["Your browser"] -->|"localhost:80"| I["ingress-nginx"]
subgraph K["kind cluster nw-lab"]
I --> P["Osos release nw<br/>namespace northwind (M2)"]
subgraph D["namespace datastores"]
M[("MongoDB rs0")]
R[("RabbitMQ")]
C[("Redis")]
E["Mailpit"]
end
P --> M
P --> R
P --> C
P -->|"SMTP"| E
end
What to notice: the platform and its datastores live in separate namespaces. The platform only knows the datastores’ addresses, exactly as it would with a managed database in production.
Sizing
Section titled “Sizing”The whole platform runs about fifteen pods. Give Docker at least 6 CPU cores and 16 GB of memory
and keep 30 GB of disk free; with less, pods stay Pending or are killed for memory during the first
install.
kind or k3d
Section titled “kind or k3d”The steps use kind. If you prefer k3d, create the cluster with
k3d cluster create nw-lab -p "80:80@loadbalancer" -p "443:443@loadbalancer" --k3s-arg "--disable=traefik@server:0"
and install ingress-nginx from its Helm chart; every later step is the same.
⛏ Lab (43 min) — Build and verify the lab
Section titled “⛏ Lab (43 min) — Build and verify the lab”Goal. A running nw-lab cluster with ingress, the three datastores and Mailpit, each proven to
answer, and the chart pulled from your vendor’s registry.
Before you start. Make a working folder, for example ~/acde-lab, and run every command from
it. Check your tools: docker version, kind version, kubectl version --client, helm version.
Create the cluster
-
Save this as
kind-nw-lab.yaml. It labels the node for the ingress controller and maps your ports 80 and 443 into the cluster.kind: ClusterapiVersion: kind.x-k8s.io/v1alpha4name: nw-labnodes:- role: control-planekubeadmConfigPatches:- |kind: InitConfigurationnodeRegistration:kubeletExtraArgs:node-labels: "ingress-ready=true"extraPortMappings:- { containerPort: 80, hostPort: 80, protocol: TCP }- { containerPort: 443, hostPort: 443, protocol: TCP } -
Create the cluster:
kind create cluster --config kind-nw-lab.yaml. It takes about a minute and switches yourkubectlcontext tokind-nw-lab. -
Install the ingress controller built for kind, and wait for it:
Terminal window kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yamlkubectl wait -n ingress-nginx --for=condition=ready pod \-l app.kubernetes.io/component=controller --timeout=180s
Run the datastores
-
Save this as
datastores.yaml. Read it before you apply it: it is the whole lab back end.# LAB ONLY: single copies, no TLS, throwaway passwords. Never use in production.apiVersion: v1kind: Namespacemetadata: { name: datastores }---apiVersion: v1kind: Servicemetadata: { name: mongo, namespace: datastores }spec:clusterIP: Noneselector: { app: mongo }ports: [{ name: mongo, port: 27017 }]---apiVersion: apps/v1kind: StatefulSetmetadata: { name: mongo, namespace: datastores }spec:serviceName: mongoreplicas: 1selector: { matchLabels: { app: mongo } }template:metadata: { labels: { app: mongo } }spec:containers:- name: mongoimage: mongo:7.0args: ["--replSet", "rs0", "--bind_ip_all"]ports: [{ containerPort: 27017 }]volumeMounts: [{ name: data, mountPath: /data/db }]volumeClaimTemplates:- metadata: { name: data }spec:accessModes: ["ReadWriteOnce"]resources: { requests: { storage: 5Gi } }---apiVersion: apps/v1kind: Deploymentmetadata: { name: rabbitmq, namespace: datastores }spec:selector: { matchLabels: { app: rabbitmq } }template:metadata: { labels: { app: rabbitmq } }spec:containers:- name: rabbitmqimage: rabbitmq:3.13-managementenv:- { name: RABBITMQ_DEFAULT_USER, value: lab }- { name: RABBITMQ_DEFAULT_PASS, value: lab-only-rabbit }ports: [{ containerPort: 5672 }, { containerPort: 15672 }]---apiVersion: v1kind: Servicemetadata: { name: rabbitmq, namespace: datastores }spec:selector: { app: rabbitmq }ports: [{ name: amqp, port: 5672 }, { name: management, port: 15672 }]---apiVersion: apps/v1kind: Deploymentmetadata: { name: redis, namespace: datastores }spec:selector: { matchLabels: { app: redis } }template:metadata: { labels: { app: redis } }spec:containers:- name: redisimage: redis:7.2args: ["--requirepass", "lab-only-redis"]ports: [{ containerPort: 6379 }]---apiVersion: v1kind: Servicemetadata: { name: redis, namespace: datastores }spec:selector: { app: redis }ports: [{ name: redis, port: 6379 }]---apiVersion: apps/v1kind: Deploymentmetadata: { name: mailpit, namespace: datastores }spec:selector: { matchLabels: { app: mailpit } }template:metadata: { labels: { app: mailpit } }spec:containers:- name: mailpitimage: axllent/mailpit:v1.20ports: [{ containerPort: 1025 }, { containerPort: 8025 }]---apiVersion: v1kind: Servicemetadata: { name: mailpit, namespace: datastores }spec:selector: { app: mailpit }ports: [{ name: smtp, port: 1025 }, { name: web, port: 8025 }] -
Apply it and wait until every pod is ready:
kubectl apply -f datastores.yamlthenkubectl -n datastores wait --for=condition=ready pod --all --timeout=300s. -
Turn MongoDB into a one-member replica set. Osos expects a replica set, and this is the smallest one there is:
Terminal window kubectl -n datastores exec mongo-0 -- mongosh --quiet --eval \'rs.initiate({_id:"rs0",members:[{_id:0,host:"mongo-0.mongo.datastores.svc.cluster.local:27017"}]})'
Prove each one answers
- MongoDB:
kubectl -n datastores exec mongo-0 -- mongosh --quiet --eval 'rs.status().ok'prints1. - Redis:
kubectl -n datastores exec deploy/redis -- redis-cli -a lab-only-redis pingprintsPONG(ignore the warning about a password on the command line: lab only). - RabbitMQ:
kubectl -n datastores exec deploy/rabbitmq -- rabbitmq-diagnostics -q pingprintsPing succeeded. - Mailpit: run
kubectl -n datastores port-forward svc/mailpit 8025:8025, openhttp://localhost:8025in your browser, and see an empty inbox. Stop the port-forward with Ctrl+C. - Ingress:
curl -s -o /dev/null -w "%{http_code}\n" http://localhost/prints404. That is good: the controller answers, and nothing is routed yet.
Pull the chart
- Log in to your vendor’s registry. Type the token at the prompt rather than on the command line,
so it stays out of your shell history:
helm registry login <registry from your vendor> --username <user from your vendor>. - Pull and unpack the chart:
helm pull oci://<chart reference from your vendor> --version <chart version> --untar. A folderosos/appears, holdingChart.yaml,values.yamlandtemplates/. - Read the version:
grep -E "^(version|appVersion)" osos/Chart.yaml. Write both numbers down; the course was written against chart1.11.0and app version1.10.0.
Check.
-
kubectl config current-contextprintskind-nw-lab. - The ingress controller pod is
Runningandcurl http://localhost/returns404. -
mongo-0answersrs.status().okwith1. - Redis answers
PONGand RabbitMQ answersPing succeeded. - Mailpit’s inbox opens at
http://localhost:8025through the port-forward. -
osos/Chart.yamlexists and you noted itsversionandappVersion. - No file in your working folder contains your registry token.
Pass condition. All seven checks hold. The lab cluster is the starting state for M1.
If something goes wrong
| What you see | What to do |
|---|---|
kind create cluster fails on port 80 or 443 | Another program (a local web server, another cluster) holds the port. Stop it, or change hostPort to 8080 and 8443 and use localhost:8080 everywhere after. |
Datastore pods stay Pending | Docker has too little memory or CPU. Raise the limits in Docker’s settings, then kind delete cluster --name nw-lab and start again. |
rs.initiate says “already initialized” | You ran it twice. Nothing to do: check rs.status().ok. |
rs.status().ok prints an error about no replica set config | Step 6 did not run, or ran before the pod was ready. Run it again. |
helm registry login answers 401 or unauthorized | The user or token is wrong or expired. Check them against the pack; ask your vendor if they still fail. |
helm pull answers not found | The chart reference or version is mistyped. Copy both from the pack exactly. |
curl http://localhost/ hangs instead of returning 404 | The ingress controller is not ready yet, or port 80 is not mapped. Re-run the wait in step 3 and check docker ps shows 0.0.0.0:80->80. |
Model answer
A correct lab, seen from kubectl get pods -A (names shortened):
| Namespace | Pod | Status |
|---|---|---|
ingress-nginx | ingress-nginx-controller-… | Running |
datastores | mongo-0 | Running |
datastores | rabbitmq-… | Running |
datastores | redis-… | Running |
datastores | mailpit-… | Running |
The two ingress admission jobs show Completed, which is normal. The addresses you will give the
chart in M2-S1 are the in-cluster Service names: mongo-0.mongo.datastores.svc.cluster.local:27017
for MongoDB, rabbitmq.datastores.svc.cluster.local (ports 5672 and 15672), redis.datastores.svc.cluster.local:6379
and mailpit.datastores.svc.cluster.local:1025. To start again from nothing at any time:
kind delete cluster --name nw-lab, then repeat from step 2.
✓ Practice (5 min) — Check your lab knowledge
Section titled “✓ Practice (5 min) — Check your lab knowledge”Why does the lab run MongoDB, RabbitMQ and Redis in their own namespace instead of letting the chart install them?
Check your answer
The correct answer is A. Open the explanation under each option to see why.
Your teammate’s lab MongoDB runs as a plain single server, without --replSet. What should they
change before installing the platform?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
After step 11, curl http://localhost/ returns 404. What does that tell you?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
Why does step 12 have you type the registry token at a prompt?
Check your answer
The correct answer is C. Open the explanation under each option to see why.
↺ Recap (1 min) — After Module 0 you can
Section titled “↺ Recap (1 min) — After Module 0 you can”After this module you can say what is your job as the operator, confirm you have the skills the course assumes, and stand up and verify a local evaluation cluster with the three datastores, a mail catcher and the chart.
Next. In M1 you read the chart before you install it: what it will create, how the parts talk to each other, and what stops when one of them fails.