Kubernetes becomes easier to understand when you can break something small and watch it recover. In this workshop you will serve the nginx welcome page, inspect the objects behind it, delete a Pod, and diagnose a Service with the wrong selector.
Adapted from the containers, local cluster, and reconciliation labs in week 1 of the Kubernetes tutorial course, with a focused Sofka walkthrough. This is a self-contained introduction; you do not need the course repository, a cloud account, Helm, or a remote server.
Verified locally: kind 0.33.0, Kubernetes 1.37.0, kubectl 1.37.1, and Sofka 0.31.10 on macOS with OrbStack. The deployment, scaling, Pod replacement, selector failure, and recovery steps were run against a fresh cluster.
You need: a terminal, an editor, basic shell commands, and a working Docker-compatible container runtime. Use macOS, Linux, or a Linux shell in Windows/WSL2. On WSL, run kind, kubectl, and Sofka inside the same distribution and enable your runtime’s WSL integration. Allow extra time for installation and image downloads. For this small lab, start with roughly 4 GB RAM and 2 CPU cores available to your runtime; that is a planning allowance, not a guaranteed minimum.
The distinction to keep in mind: kind creates the cluster. kubectl and Sofka talk to its API. A Deployment declares how many copies of your application should run. A Service provides a stable way to reach matching Pods. Your browser reaches a Pod through a local port-forward during this lab.
| Lesson | Time | Checkpoint |
|---|---|---|
| 1. Create your cluster | 20 min | One Ready node |
| 2. Connect Sofka | 15 min | The same context in both clients |
| 3. Run a workload | 25 min | Two ready nginx replicas |
| 4. Reach it and read its logs | 15 min | HTTP 200 and an access log |
| 5. Scale, break, and recover | 30 min | Replacement Pod and repaired selector |
| 6. Prove it and clean up | 15 min | Evidence you can explain |
1. Create your cluster
We use kind because it runs Kubernetes nodes as containers and makes a disposable lab easy to reproduce. k3s is another lightweight distribution, and k3d runs k3s in containers. Choose one path for this session: the commands below use kind throughout. You can transfer the workload and kubectl concepts to another cluster later.
Start your container runtime first. On macOS with Homebrew, install the command-line tools:
brew install kind kubectl
brew install nklmilojevic/sofka/sofka On Linux or WSL, use the official kind installation guide, kubectl installation guide, and Sofka releases and installation instructions. Choose binaries for your machine’s architecture. Installing the Docker CLI alone does not start a container runtime.
docker info
kind version
kubectl version --client
sofka --version Checkpoint: Docker reports a server, and all three tools report versions. If Docker cannot connect, start the runtime before continuing.
Create a dedicated working directory and kubeconfig. Run this once in your first terminal:
mkdir -p "$HOME/local-k8s-workshop"
cd "$HOME/local-k8s-workshop"
export KUBECONFIG="$PWD/kubeconfig"
kind create cluster --name workshop-local --kubeconfig "$KUBECONFIG" --wait 120s
kubectl config current-context
kubectl cluster-info
kubectl get nodes -o wide
kubectl get pods -A The context should be kind-workshop-local and the node should become Ready. -A lists all namespaces, including Kubernetes’ own system Pods. Initial image pulls can take a few minutes. If creation fails, inspect the runtime and kind export logs --name workshop-local before retrying; do not create a second cluster under another name to hide the error.
A kubeconfig records the API address, credentials, and contexts. A context combines a cluster, identity, and optional default namespace. Keeping this file separate avoids switching your usual work context. Do not commit it or include it in screenshots.
In every additional terminal, repeat these two lines before any command in this workshop:
cd "$HOME/local-k8s-workshop"
export KUBECONFIG="$PWD/kubeconfig" 2. Connect Sofka to the same cluster
Create the namespace that will contain our application, then check Sofka’s connection:
kubectl --context kind-workshop-local create namespace workshop
sofka --kubeconfig "$KUBECONFIG" --context kind-workshop-local --check
sofka --kubeconfig "$KUBECONFIG" --context kind-workshop-local -n workshop --readonly Leave Sofka open in this terminal and use another terminal for kubectl. Its header should show kind-workshop-local, the workshop namespace, and read-only mode. An empty Pods list is correct: we have not deployed anything yet. Sofka uses the same Kubernetes credentials; it does not need an agent installed into this cluster.
Read-only mode keeps our mutations in the command history while Sofka acts as our observation window. Follow the on-screen hints and press ? for the bindings in your installed version. With the default bindings:
| In Sofka | What to inspect | kubectl equivalent |
|---|---|---|
Type :pods, Enter | Pod readiness, state and restarts | kubectl -n workshop get pods |
Type :deployments, Enter | Desired and available replicas | kubectl -n workshop get deployments |
Type :services, Enter | Service type and ports | kubectl -n workshop get services |
Select a Pod, press d | Conditions and recent events | kubectl -n workshop describe pod POD_NAME |
Select a Pod, press y | The live object as YAML | kubectl -n workshop get pod POD_NAME -o yaml |
Select a Pod, press l | Container logs | kubectl -n workshop logs POD_NAME |
POD_NAME is a placeholder: substitute an actual name from your Pods list. Press Escape to return from a detail view. These commands and keys are documented in the Sofka project. CPU and memory usage may be unavailable on a fresh kind cluster without Metrics Server; that does not mean the workload has failed.
3. Run a workload
Download web.yaml into your workshop directory, or create a file with the full contents below. YAML indentation is significant; use spaces.
web.yaml — Namespace, Deployment, and Service
apiVersion: v1
kind: Namespace
metadata:
name: workshop
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
namespace: workshop
spec:
replicas: 2
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: nginx
image: nginx:stable
ports:
- name: http
containerPort: 80
resources:
requests:
cpu: 100m
memory: 64Mi
limits:
cpu: 500m
memory: 128Mi
readinessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 2
periodSeconds: 3
---
apiVersion: v1
kind: Service
metadata:
name: web
namespace: workshop
spec:
selector:
app: web
ports:
- name: http
port: 80
targetPort: http
Read the manifest before applying it. replicas: 2 asks for two Pods. The Deployment’s selector matches the labels on its Pod template. The Service uses that same app: web label to find its backends. Its port 80 points to the container port named http. The readiness probe requests /; a Pod only becomes a ready backend after the probe succeeds. Resource requests help scheduling; limits bound each container’s CPU and memory use.
kubectl config current-context
# Confirm kind-workshop-local before making changes.
kubectl --context kind-workshop-local apply -f web.yaml
kubectl -n workshop rollout status deployment/web --timeout=120s
kubectl -n workshop get deployments,replicasets,pods,services apply -f submits the desired configuration from a file. Reapplying this file updates the same named objects. rollout status waits for the Deployment to make its replicas available; it is more useful than assuming an accepted API request means the application is ready.
Checkpoint: Deployment web shows 2/2 ready, and both Pods show 1/1 Running. Switch Sofka to :pods to see those same names. Inspect one Pod’s YAML and find its app: web label and owner reference. The ReplicaSet owns the Pods; the Deployment manages the ReplicaSet.
The lab uses nginx:stable for readability; this tag can change. Record the image actually pulled, and pin its digest in web.yaml if you need to reproduce exactly the same build:
kubectl -n workshop get pods -l app=web -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.containerStatuses[0].imageID}{"\n"}{end}' 4. Reach the workload and read its logs
In a separate terminal with the workshop kubeconfig exported, run:
kubectl -n workshop port-forward --address 127.0.0.1 service/web 8080:80 Keep it running. 8080:80 means local port 8080 to the Service’s port 80. Open http://127.0.0.1:8080 in your browser. In your command terminal:
curl -i http://127.0.0.1:8080
kubectl -n workshop logs -l app=web --prefix --tail=20
kubectl -n workshop get endpointslices -l kubernetes.io/service-name=web Checkpoint: curl reports HTTP 200, your browser shows the nginx welcome page, and one Pod’s access log contains your request. In Sofka, select that Pod and press l. If the selected Pod has no request, inspect the other one: the port-forward chooses a backend Pod, rather than balancing each request across both replicas.
A ClusterIP Service is internal to the cluster. Port-forward opens a temporary tunnel through the Kubernetes API to a selected Pod; it does not test the Service’s normal cluster-IP routing. EndpointSlices show the backends associated with a Service. Read more in the official Service debugging guide.
5. Scale, break, and recover
Change the desired number of replicas
kubectl --context kind-workshop-local -n workshop scale deployment/web --replicas=3
kubectl -n workshop rollout status deployment/web --timeout=120s
kubectl -n workshop get pods -l app=web Watch the third Pod appear in Sofka. This changes the live object; your file still says two. Restore the manifest’s desired state:
kubectl --context kind-workshop-local apply -f web.yaml
kubectl -n workshop rollout status deployment/web --timeout=120s Delete one Pod and watch reconciliation
In one terminal, start a watch:
kubectl -n workshop get pods -l app=web -w In another, select and delete exactly one of this lab’s Pods:
WORKSHOP_POD=$(kubectl -n workshop get pods -l app=web -o jsonpath='{.items[0].metadata.name}')
printf '%s\n' "$WORKSHOP_POD"
kubectl --context kind-workshop-local -n workshop delete pod "$WORKSHOP_POD"
kubectl -n workshop rollout status deployment/web --timeout=120s The replacement has a new name and identity. Kubernetes did not resurrect the old Pod: the ReplicaSet created another to return to two desired replicas. This is reconciliation. Stop the watch with Ctrl-C. If the deleted Pod held your port-forward, restart the forwarding command and confirm HTTP 200 again.
Give the Service the wrong selector
Stop your existing port-forward with Ctrl-C first. An already-open tunnel can keep reaching a Pod after a selector changes, which would make this experiment misleading.
kubectl --context kind-workshop-local -n workshop patch service web --type merge -p '{"spec":{"selector":{"app":"missing"}}}'
kubectl -n workshop get pods --show-labels
kubectl -n workshop get service web -o yaml
kubectl -n workshop get endpointslices -l kubernetes.io/service-name=web -o yaml Wait a few seconds for the EndpointSlice controller to catch up. The Pods remain healthy, but the Service no longer selects them: its slices have no backend addresses. Try a new port-forward with a short wait:
kubectl -n workshop port-forward --pod-running-timeout=10s service/web 8080:80 It should time out because no Pod matches app: missing. In Sofka, inspect :services, select web, and press y; compare its selector with a Pod’s labels. A healthy Pod is only one part of a working request path.
Repair the selector by reapplying the original file, then verify backends and HTTP again:
kubectl --context kind-workshop-local apply -f web.yaml
kubectl -n workshop get endpointslices -l kubernetes.io/service-name=web
kubectl -n workshop port-forward --address 127.0.0.1 service/web 8080:80
# In another terminal:
curl -i http://127.0.0.1:8080 A small command vocabulary
| Command | Question it answers |
|---|---|
get | What exists, and what is its current state? |
describe | What are its conditions and recent events? |
logs | What did the container write to stdout/stderr? |
apply -f | Can the cluster converge on this file’s desired state? |
rollout status | Has this Deployment become available? |
scale | What happens if I change the desired replica count? |
port-forward | Can I reach a selected Pod from my laptop? |
delete pod | Will its controller replace it? |
The usual shape is kubectl -n NAMESPACE VERB RESOURCE NAME. -l app=web filters by label; -o yaml changes the output format; -w keeps watching. A namespace scopes namespaced objects, while --context chooses which cluster and credentials to use.
6. Prove it and clean up
Before looking back at the commands, demonstrate these five things:
- Show the local context and a Ready node.
- Show two ready web Pods in both kubectl and Sofka.
- Retrieve the welcome page and locate its access log.
- Delete one Pod and explain why its replacement has a different name.
- Explain why the broken selector removed Service backends even though the Pods stayed healthy.
Save your manifest, tool versions, an HTTP response, and screenshots of the Pods before and after replacement. Keep credentials out of those artifacts. Independent challenge: change the manifest to three replicas, apply it, verify the result in Sofka, then restore two. Explain why an imperative scale command alone did not update the file.
If something does not work
| Symptom | Next useful check |
|---|---|
| Docker connection refused | Start the runtime; run docker info again |
| kubectl or Sofka shows another cluster | Export the workshop kubeconfig in that terminal and check the context |
| Pod is Pending | kubectl -n workshop describe pod POD_NAME; inspect scheduling events and available resources |
| ImagePullBackOff | Inspect Pod events for registry, network, or image-name errors |
| Sofka is empty | Confirm context, namespace, and any active filter; compare kubectl -n workshop get pods |
| CPU and memory columns are blank | Metrics Server is not installed; readiness and logs still work |
| Port 8080 is occupied | Use 8081:80 and visit port 8081 instead |
| Page stops responding after Pod deletion | Restart port-forward; it does not follow a replaced Pod |
| Service has no backends | Compare selector, Pod labels, and readiness; inspect EndpointSlices |
When finished, stop port-forwards and quit Sofka. Remove just this lab’s namespace if you want to keep the cluster:
kubectl --context kind-workshop-local delete namespace workshop Or remove the entire disposable cluster after saving your evidence:
kind delete cluster --name workshop-local
unset KUBECONFIG Do not run a global Docker prune. The downloaded manifest remains available for rebuilding the lab. Your next step in the full course is to build your own application image, load it into kind, and add health checks and configuration.