There once was a little app, proudly running in a container. The container let the app have its favorite operating system and libraries, all snug and separate.
The little app shared a container runtime with its friend, a firefly.
Sometimes the app’s code would crash (through no fault of the code, of course; must have been bad input). Then the little app would ask the computer to please start up its container again.
Over time, the app and the firefly made more friends, and found they could all run their code in different containers in the same runtime, on the same computer, without interfering with each other. (Everyone trusted each other to be polite.)
They met a nice oriole (which definitely did not eat fireflies), and a mantis shrimp, and about a hundred toads. Everyone’s app ran in a container.
Soon the container runtime was very busy!
Fortunately, now that the friends were so many, they could afford another computer. And another! And another!
Pretty soon the friends shared a whole group of computers.
Sometimes one computer was too busy, so the little app would try each of the others until it found one where its container ran comfortably.
Having more than one computer came in handy sometimes. One day, lightning struck and took one computer down. The little app started up his container on another.
After that, about a hundred toads (who each had the same app) started dividing up their containers between all the computers. If one computer stopped, their apps kept running on the others. The toads’ customers never even knew about the hungry guinea pig who ate straight through a network cable.
It’s a good thing there were so many toads, because it was a lot of work checking all the time how many of their containers were running on each computer. About a hundred toads were always shutting down some containers and starting up others to get them nice and even, like icing on a cake that you buy at a store.
While everyone liked each other and tried to get along, still there were challenges.
The firefly and the mantis shrimp got frustrated with nearly a hundred toads moving their app instances all the time, because computers that had space one minute would be too busy the next.
The nice oriole chirped sharply at the mantis shrimp for running her app on three computers at once. “Oh, pardon me!” said the mantis shrimp, “I did not realize it was still running there. Perhaps this explains its recent strange behavior.”
Meanwhile the little app wasn’t getting enough sleep. It kept its phone close, so if someone complained it could restart its container. More people depended on it now.
The firefly tried to help by restarting his friend’s app, but he messed it up. The firefly didn’t know that the little app ran on a different port than the firefly’s did. The firefly had to wake his friend up from a deep sleep: “I’m so sorry. Tell me how your app works again?”
Finally the little app called a meeting of all the runtime-sharing friends.
“Does anyone else feel like it’s a lot of work to keep their app container running?” it asked.
“So much work,” about a hundred toads agreed. “Work.” “Work.”
The mantis waved a club: “A constant level of attention is required. This is not ideal.”
“My song is cut short by the incessant surprise,” reported the nice oriole.
The little app sighed. “I wish I could spend more time on my code, and less time starting and stopping my container over and over.”
The firefly blinked in solidarity.
“If only we could harness the power of the computers to maintain our containers in optimal status,” intoned the mantis shrimp, flashing her antennal scales.
“Our computers are too busy as it is,” the little app responded, despairing.
Just then, in the silence, an owl descended into the center of the group. Softly, she suggested: “Perhaps this is a time for kubernetes.”
“What?” “What?” “Kuberwhat?” about a hundred toads croaked.
The owl explained: “Kubernetes is software that works with your container runtime to keep just the right containers running.”
The nice oriole cocked his head to the side. “So we can tell each computer which containers to run, and it will restart them without our help?”
The owl stood taller. “Oh, better than that. Kubernetes works across computers. It will choose a computer for you, so that each computer is busy enough, and never too busy.”
Mantis shrimp forearms stood straight up.
The firefly blinked faster.
“Let’s try it!” said the little app.
“O-kay,” the owl hooted in approval. “Each of you, please write down what your containers need. What ports do they like? Do they have any secrets? How busy will they make the computer? How do you know the app is working? How many of the same one should be running?”
Each of the friends sat down and thought about it. About a hundred toads conferred amongst themselves, which was a lot of croaking, which made it hard to think.
Meanwhile, the owl sat down with the mantis shrimp. Together they installed enough of kubernetes on each computer.
“Now,” said the owl, “Your computers form a cluster!
“It is time to offer your deployments to kubernetes.”
“What?” “What?” “Offer our what?” from about a hundred toads.
“You are making a deployment specification. This tells kubernetes what containers to keep running,” announced the mantis shrimp. He had been listening carefully.
The little app bravely approached with its file, answering all the owl’s questions. The owl corrected its formatting, then submitted it to kubernetes. Kubernetes replied with an error. The owl corrected some spelling and tried again. Kubernetes replied with an error. The owl snapped her beak and replaced all tabs with spaces. Finally kubernetes accepted it.
At first, nothing happened. Then:
“It’s up!” said the little app. “I’m running!” It tested itself quickly.
“Let’s see what happens when I crash,” said the app, and bravely typed in some very bad input.
The firefly blinked in suspense.
“It’s down,” announced the little app. Then, seconds later, “Now I’m up! I’m up again!”
The owl hooted. “Kubernetes noticed that your container stopped responding. It replaced it with a new one.”
All the friends saw their containers running smoothly, spread across the nodes. There was even room for a few more, because the containers were distributed so efficiently!
“Now, save those files you made,” warned the wise owl. “They record what you asked kubernetes to do, and you will want them in the future.”
From that day on, the friends didn’t worry about their containers. They worked on their code instead! Or their singing.
Except: someone still had to keep kubernetes running. Fortunately, the mantis shrimp was into it.
“We have directed the power of computers onto themselves!” he cried joyfully, punching the air with his clubs.
The mantis shrimp enjoyed operating kubernetes, because there was always more to learn.
For instance: very soon, about a hundred toads came to the mantis shrimp. They had changed some code and wanted to update their app.
“We need to change about a hundred containers,” one toad said.
“But not all at once!” another toad chimed in. “A few,” “A few,” “then a few more,” the other toads croaked.
“What do we type?” asked the final toad.
The mantis shrimp lowered her eyes. “I do not yet know. I must consult the owl.” He clacked his clubs together as a signal.
Soon the owl flew down. When she heard the toad’s question, she hooted. “You need only update the container name in the deployment. A single change! Kubernetes will do the rest.”
The toads dug up the file that defined their deployment. They changed one line and submitted this to kubernetes. Sure enough, their containers gradually stopped and restarted with the new code.
“Declare what should be, and kubernetes shall make it so!” the mantis shrimp danced. “Magic!”
“Easy!” “Easy!” “Easy and fast!” about a hundred toads celebrated. After that, they changed their app several times a day, without disrupting their swim time.
The little app was happy, and every week he brought the mantis shrimp tasty snacks to thank him for his work.
“It is no problem,” said the mantis shrimp. “You should see the consulting rates I can charge now that I have production experience with kubernetes!”