Your DevOps study space

Real explanations. Videos with tests. Fresh exams every time. Keep the streak alive and watch the XP stack up.

Your first cluster, hands-on · Kubernetes Docs · StackwisePlanDevOps Your first cluster, hands-on · Kubernetes Docs · StackwiseCodePython Your first cluster, hands-on · Kubernetes Docs · StackwiseBuildDocker Your first cluster, hands-on · Kubernetes Docs · StackwiseTestDevOps Your first cluster, hands-on · Kubernetes Docs · StackwiseReleaseGit Your first cluster, hands-on · Kubernetes Docs · StackwiseDeployKubernetes Your first cluster, hands-on · Kubernetes Docs · StackwiseOperateLinux Your first cluster, hands-on · Kubernetes Docs · StackwiseMonitorDevOps

Pick a topic

Eight tracks, each with docs, a cheat sheet, videos and tests.

How it works

One loop, repeated until it sticks.

Jump back in

Picked up from where you left off.

Free forever

Your DevOps journey starts with one click.

Sign in with Google or GitHub to open every chapter, video, test and challenge. Your progress is saved wherever you learn.

Your first cluster, hands-on

Reading about Pods and Services only goes so far. In this chapter you build a real Kubernetes cluster on your own laptop, deploy an app to it, reach it, scale it, update it, break it on purpose and clean up. Everything runs inside Docker, so it costs nothing and leaves nothing behind.

kind or minikube?

Both give you a working cluster on one machine. kind ("Kubernetes in Docker") runs each Kubernetes node as a Docker container: it starts in under a minute, is very light, and is what many CI pipelines use to test against a real cluster. minikube runs a single node in a container or VM and comes with handy add-ons (dashboard, ingress, metrics-server). Either is fine for learning; this chapter uses kind, and the minikube equivalents are at the end. You need Docker running (Linux chapter 11 sets it up).

Install kubectl and kind

On a Mac, brew install kubectl kind does both. On Linux or WSL (Intel/AMD machines), download the binaries:

# kubectl: the client you'll use for every cluster, local or cloud
$ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
$ sudo install -m 0755 kubectl /usr/local/bin/kubectl

# kind: check kind.sigs.k8s.io for the newest version number
$ KIND_VERSION=v0.24.0
$ curl -Lo ./kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64
$ chmod +x ./kind && sudo mv ./kind /usr/local/bin/kind

$ kubectl version --client
$ kind version

Create the cluster

$ kind create cluster --name dev
Creating cluster "dev" ...
 ✓ Ensuring node image
 ✓ Preparing nodes
 ✓ Starting control-plane
Set kubectl context to "kind-dev"

$ kubectl get nodes
NAME                STATUS   ROLES           AGE   VERSION
dev-control-plane   Ready    control-plane   45s   v1.31.0    # yours may be newer

kind also wrote the connection details into ~/.kube/config, the kubeconfig file every kubectl command reads. That's why kubectl "just knows" where the cluster is.

Contexts and namespaces

A context in the kubeconfig is a saved combination of a cluster, a user and a default namespace. When you also work with a cloud cluster, switching context is how you choose which cluster a command hits, so always check before running anything destructive.

$ kubectl config get-contexts        # all saved contexts, * marks the current one
$ kubectl config current-context
kind-dev
$ kubectl config use-context kind-dev

A namespace is a folder inside a cluster. It groups related objects, lets two teams use the same names without clashing, and is the unit that access rules and resource quotas apply to. Every cluster starts with default, kube-system (Kubernetes' own parts) and a few others.

$ kubectl create namespace shop
$ kubectl config set-context --current --namespace=shop   # make it the default
$ kubectl get pods -A                                     # -A: every namespace

Deploy an app

Save this as web.yaml. It's a Deployment that keeps two copies of nginx running, and a Service that gives them one stable address:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  namespace: shop
spec:
  replicas: 2
  selector:
    matchLabels: {app: web}
  template:
    metadata:
      labels: {app: web}
    spec:
      containers:
        - name: web
          image: nginx:1.27
          ports:
            - containerPort: 80
          resources:
            requests: {cpu: 50m, memory: 32Mi}
            limits: {memory: 128Mi}
---
apiVersion: v1
kind: Service
metadata:
  name: web
  namespace: shop
spec:
  selector: {app: web}
  ports:
    - port: 80
      targetPort: 80
$ kubectl apply -f web.yaml
deployment.apps/web created
service/web created
$ kubectl rollout status deployment/web
deployment "web" successfully rolled out
$ kubectl get deploy,rs,pods -o wide

Reach it

The Service is type ClusterIP, so it's only reachable from inside the cluster. For testing from your laptop, port-forward opens a tunnel through kubectl:

your laptopcurllocalhost:8080kubectlport-forwardkind cluster (a Docker container)svc/web:80 ClusterIPpod: nginx:80tunnel
A ClusterIP Service is invisible from outside the cluster. Port-forward borrows kubectl's connection to reach it, for you only, while the command runs.
$ kubectl port-forward svc/web 8080:80
Forwarding from 127.0.0.1:8080 -> 80
# in a second terminal:
$ curl -I localhost:8080
HTTP/1.1 200 OK
Server: nginx/1.27.x

Port-forward is for you, not for users. Real traffic comes in through an Ingress or a LoadBalancer Service (Kubernetes chapter 4).

Scale, update, roll back

$ kubectl scale deployment/web --replicas=4
$ kubectl set image deployment/web web=nginx:1.27-alpine   # container name = new image
$ kubectl rollout status deployment/web                    # watch pods being replaced one by one
$ kubectl rollout history deployment/web
$ kubectl rollout undo deployment/web                      # back to the previous version

In real projects you'd change the image in web.yaml and kubectl apply it again, so the file in Git always matches what's running. The commands above are just the quickest way to see it happen.

Break it on purpose

Point the Deployment at an image that doesn't exist and watch how Kubernetes reports it:

$ kubectl set image deployment/web web=nginx:does-not-exist
$ kubectl get pods
web-7c9d...   0/1   ImagePullBackOff   0   30s
$ kubectl describe pod web-7c9d...      # read the Events at the bottom
  Failed to pull image "nginx:does-not-exist": ... not found
$ kubectl rollout undo deployment/web   # fix it

Notice the old pods kept serving while the broken ones failed: a rolling update only removes old pods when new ones become ready. Now delete a pod by hand with kubectl delete pod <name> and run kubectl get pods again. A new one appears within seconds, because the ReplicaSet always works back to the number you asked for.

Run your own image

The cluster's nodes are containers, so they can't see images you've only built on your laptop. Load them in first:

$ docker build -t myapp:dev .
$ kind load docker-image myapp:dev --name dev
# then use image: myapp:dev in the Deployment

Use a real tag like dev, not latest: with latest, Kubernetes always tries to pull from a registry and fails with ImagePullBackOff.

Clean up

$ kubectl delete namespace shop     # deletes everything inside it
$ kind delete cluster --name dev    # removes the whole cluster

The same steps on minikube

$ minikube start                          # instead of kind create cluster
$ minikube image load myapp:dev           # instead of kind load docker-image
$ minikube service web -n shop --url      # prints a URL that reaches the Service
$ minikube addons enable ingress          # a ready-made Ingress controller
$ minikube delete

Common problems

  • The connection to the server localhost:8080 was refused: kubectl has no cluster to talk to. Check kubectl config get-contexts, and that Docker (and the kind containers) are running.
  • Pods stuck in Pending: kubectl describe pod usually says Insufficient cpu or memory. Give Docker Desktop more resources, or lower the requests.
  • ImagePullBackOff for your own image: you forgot kind load, or used the latest tag.
  • Changes "don't apply": you're in a different namespace or context than you think. kubectl config get-contexts shows both.

Questions

Pick an answer. Get it wrong and you can try again right away, no waiting. 10 questions per topic - pick a filter below, then use Recreate questions for a fresh set on that topic.

Fresh questions every time

Exam

A mixed test across the whole site, shuffled so you never know which topic comes next. When you submit, every mistake comes with the reason and a jump to the exact moment in the video that explains it.

30 questions 6 topics 20 minute limit Up to 70 XP
1–4 answer · ←→ move
History

Essay

0 / 200-250 words
Sample answer
History
0:00 / 0:00
Not started

on YouTube
Subscribe

Topic progress

Activity

Achievements

Settings

Your profile and your account.

Profile details

* Required. Saved in this browser until you sign in.

Letters, numbers, dots, dashes and underscores.
0 / 160

Account

Checking…

App

Install Stackwise on your phone or computer. It opens in its own window from your home screen, and the Docs and cheat sheets you've opened keep working without internet.

Only admins can see this

Dashboard

Sign-ups, activity, messages and reviews in one place.

Prove it

Certificates

Pass a topic's test and get a certificate with its own public page you can share or add to LinkedIn. Each test is 10 questions drawn at random and graded on the server; you need 8 right, you have 15 minutes, and you get one try per topic a day.

From first command to production

Linux for DevOps

A path through Linux the way DevOps engineers use it: ten stages, every command explained with its flags, examples, real output and mistakes, the combinations engineers chain together, and incidents worked through step by step. Practise everything in a safe lab folder.

Before the interview

Interview prep

Questions that come up in real DevOps interviews, with the kind of answer that lands. Say yours out loud first, then compare. Each one links to the chapter that goes deeper.

    Private to you

    My notes

    Everything you wrote down while watching and reading, in one place. Saved to your account, never shown to anyone.