Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Setting up Kubernetes  ›  Lesson

Installing a Local Cluster

Installing a Local Cluster 12 minA local tool such as kind or minikube creates a practice cluster, and kubectl reaches it through a context stored in the kubeconfig file.

Installing a Local Cluster

You would not learn to drive on a motorway. A local cluster is your empty car park: a real Kubernetes, on your own laptop, that costs nothing and that you can break and rebuild in a minute.

The rule

Two tools, one file: a cluster, kubectl, and the kubeconfig that joins them.

You need three things:

  1. A local cluster tool. Popular choices:
    • kind ("Kubernetes in Docker") — runs each node as a Docker container. Fast to create and destroy; great for experiments and CI.
    • minikube — a single-node cluster in a VM or container, with handy add-ons such as a dashboard.
    • k3d — runs k3s, a lightweight Kubernetes distribution, inside Docker.
    • Docker Desktop — has a Kubernetes switch in its settings.
  2. kubectl — the command-line client that talks to any cluster's API server.
  3. A kubeconfig file, usually ~/.kube/config. It stores each cluster's address and credentials as a context. Local tools write this for you.

With kind and Docker installed:

kind create cluster --name notes
kubectl config current-context
kubectl get nodes

The second command prints kind-notes; the third lists one node with status Ready.

The shortcut

Before any command, ask "which cluster am I pointed at?" Every kubectl command goes to the current context. Check it, then act.

Setting up a practice clusterStep 1 of 4
  1. Create

    kind create cluster --name notes starts a node container and adds a kind-notes context to your kubeconfig.

The trap is a stale context. If you tested against a company cluster yesterday, today's kubectl delete still goes there. kubectl config use-context kind-notes switches the pointer back.

Drills

Answer fast — trust the rule.

quick drill

How does kind run a Kubernetes node?

quick drill

Where does kubectl find a cluster's address and credentials?

quick drill

Which command shows the cluster your next kubectl command will hit?

quick drill

You have contexts kind-notes and work-prod. How do you aim kubectl at your laptop cluster?

Remember

  • A local cluster tool (kind, minikube, k3d), kubectl, and the kubeconfig that joins them.
  • Always ask "which cluster am I pointed at?" before acting.
  • Trap: a stale context sending practice commands to a real cluster.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWhich cluster am I on?

You tested commands on a company cluster yesterday and today want to practise deleting pods on your laptop's kind cluster. Explain what could go wrong and the exact steps you take to stay safe.