Your First Cluster
Your first hour: what a cluster is, how kubeconfig points you at one, and how namespaces divide it.
An interactive Kubernetes lesson: 21 steps, about 30 minutes, on a live simulation in your browser.
Your team runs a small shop on Kubernetes, and this lesson is your first hour with its cluster. A cluster is a group of machines managed as one system: you talk to the cluster, and the cluster decides which machine does the work.
On the stage you see those machines. The top band is the control plane, the programs that run Kubernetes itself: they take your commands and track everything. Below are the nodes, one machine each, where your workloads will run. kubectl, short for kube control, is the command-line tool you drive it all with.
What you will learn
Meet your cluster
- One cluster, many machines: A cluster is many machines acting as one: the control plane decides, and nodes run the workloads.
- Four programs run your pods: The API server records, etcd remembers, the scheduler places, and the kubelet on each node runs.
- Ask the cluster who it is: If kubectl answers, you are talking to a live cluster. If it does not, nothing else here can work.
- One command, one request: One kubectl command is one request to the API: an answer comes back, and kubectl exits.
Connecting with kubeconfig
- One file, three lists: kubeconfig is kubectl's address book: the clusters it can reach, the users it can be, and the contexts it can use.
- A context is a triple: A context names three things at once: which cluster, which user, and which namespace.
- Many files, one view: KUBECONFIG lists every config file; kubectl merges them and uses one context at a time.
- Drill: where am I?
Namespaces
- One cluster, many teams: A namespace divides one cluster into named scopes, so teams share machines without sharing names.
- default, kube-system, shop
- Names grow a suffix: A Service's full name is name.namespace: short names resolve at home, full names work everywhere.
- The same name twice: Names live inside namespaces: the same name in two namespaces is two different objects.
- Quotas need walls
Working in a namespace
- Point kubectl at shop: The context sets your namespace; every bare command after that runs inside it.
- One command elsewhere: The context sets your namespace, and -n overrides it for one command only.
- Drill: stay in shop
Namespace footguns
- Break it: the wrong home: What you create without -n lands in default, whatever you intended.
- Break it: one secret, one home: A Secret belongs to one namespace: a pod can only use secrets stored beside it.
- Break it: delete the walls
Recap & playground
- Cheat sheet
- Playground