What a Kubernetes cluster is made of
Kubernetes is a system that runs programs on one or more computers and keeps them running. Every table it prints uses three words, node, namespace and pod, so you need them before anything else makes sense.
A shop might run a website, a payment service and a stock service all day. Kubernetes watches each one for you.
By the end of this lesson
Note
I can say what a node, a namespace and a pod are.
Key words
| Word | What it means | Example |
|---|---|---|
| Cluster | the computers Kubernetes controls as one group | |
| Node | one machine of the cluster | |
| Namespace | a named folder that keeps one group's things apart | kube-system |
| Pod | one running copy of a program | |
| kubectl | the command that talks to the cluster |
The cells students fill in are left blank in this preview.
A cluster is made of nodes
A cluster is the group of computers Kubernetes controls. Each computer in it is a node. A real cluster has many nodes. This lab has one, so one machine does every job.
A namespace is a named folder inside the cluster. It keeps one team's things apart from another's. Kubernetes keeps its own parts in kube-system, and you put your work in a namespace you make.
Worked example: three words in this lab
| Word | What it is | Where you meet it here |
|---|---|---|
| Node | One machine of the cluster | The one machine you are logged in to |
| Namespace | A named folder of things | `default` and `kube-system` |
| Pod | One running copy of a program | The `coredns` pod in `kube-system` |
The cells students fill in are left blank in this preview.
List the namespaces
kubectl get namespaces --no-headers -o custom-columns=NAME:.metadata.nameShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
List the pods Kubernetes started
kubectl get pods -n kube-system --no-headers -o custom-columns=NAME:.metadata.nameShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
A pod is one copy of a program
A pod holds one or more containers. It has a name, and the program inside sees that name as its host name.
You can start a pod by hand with kubectl run. The -n flag says which namespace it goes in. The next Runs make a namespace called tour, start a pod called solo that sleeps for an hour, and ask it its name.
Make a namespace of your own
kubectl create namespace tourShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Start one pod by hand
kubectl run solo -n tour --image=busybox:1.37.0 -- sleep 3600Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Wait until the pod is ready
kubectl wait --for=condition=Ready pod/solo -n tour --timeout=60sShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Ask the pod its own name
kubectl exec solo -n tour -- hostnameShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
A common mistake
Warning
Many people think Kubernetes starts a pod again when it is deleted. A pod you made by hand is gone for good, because nothing owns it. Only something that owns pods, such as a Deployment, makes new ones.
Delete the pod
kubectl delete pod solo -n tour --grace-period=1Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Look for it again
kubectl get pods -n tourShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Remove the namespace
kubectl delete namespace tourShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.