What happens when you run kubectl apply
Image and container: what Kubernetes actually copies
Kubernetes runs copies of an app on many servers at the same time. But if you copy only the code to a server, the app fails at once. So what does Kubernetes really copy?
-
1
Copy only your app to a server, and it fails at once. The program that runs its language, such as Python, and its dependencies, the packages of code it uses, stayed on your laptop.
-
2
So you pack your app and everything it needs into one sealed package, called an image.
-
3
An image runs nothing by itself. A server has to start your app from it, and each running copy of the image is a container.
-
4
That answers Kubernetes: the 3 copies are 3 containers, all started from the same image.
-
5
But the image sits on your laptop, out of reach of the servers. So you send it to a registry, a store of images that servers fetch from.
-
6
Not yet. An image on a shelf runs nothing, and Kubernetes has not picked a server for any container.
-
Quick check
You fix a typo in the menu, on your laptop.
Show the answer
No. They run the image as you packed it. The fix needs a new image, and new containers started from it.
-
Go further
Two names you will meet around images.