Skip to main content
Foundations: web, servers, containersLesson 6 of 13

From One Server to Containers

Build it up one step at a time: how one physical server is split into virtual machines, and how containers run on top of them. This is the background you need to read a Kubernetes node's CPU and memory graphs and its specs.

Unit of executionProgram
Operating systemOne per server
Resources—
Physical serverHardware · LinuxProcessPID · exit codeHypervisorSplits resourcesVM 1Its own OSVM 2Its own OSContainerwebContainerapiCloudOpenStack, etc.Run program
RequestResponse / reportAppears in a later step

What you will learn

  • What CPU, memory, disk and network each do
  • Too little CPU means slow, too little memory means killed
  • Each virtual machine has a whole OS of its own
  • A container is an isolated process sharing the kernel
  • On-premises vs public vs private cloud

Physical server vs VM vs container​

TypeWhat it has on its ownTraits
Physical serverAll hardware and the OSOne program per server leaves resources unused
Virtual machineIts own OSThe hypervisor allocates and isolates resources. Heavy, since it carries a whole OS
ContainerOnly programs and librariesShares the kernel. Starts in seconds, and many more fit on one server

Where a container's source (the image) comes from is the next lesson. How a container actually starts on a node is in How a Pod Starts.

Try it yourself​

nproc; free -h; df -h # CPU, memory, disk (on a Linux server)
ps -ef | head # Processes and their PIDs
kubectl get nodes -o custom-columns=NAME:.metadata.name,CPU:.status.capacity.cpu,MEMORY:.status.capacity.memory # Node size
kubectl top nodes # CPU and memory use per node (needs metrics-server)
kubectl get pod <pod> -o jsonpath='{.status.containerStatuses[*].lastState.terminated.reason}' # OOMKilled after a memory limit?

Check yourself

  1. An app responds slowly but never crashes, while another app keeps getting killed. Which resource shortage fits each?
  2. Why do containers start in seconds and fit on a server in far greater numbers than VMs?
  3. The web container goes over its memory limit. What happens to the api container on the same server?

Further reading: Containers (Kubernetes docs) · Nodes · Resource Management for Pods and Containers