What actually is a Pod in Kubernetes?

If you ever read at least a little about Kubernetes or followed a simple tutorial, you must have come across the term "Pod".

In case you're still wondering what it is, this thread is for you!

🧵⏬
1️⃣ What is it?

A Pod is the smallest deployable unit in Kubernetes.

It's a group of one or more containers that form a logical local host. They share their storage, their network, are always co-located and co-scheduled.
The most common use case is having a Pod with exactly one container. Having multiple containers within a Pod is usually a pretty advanced use-case.

So, naively spoken, a Pod is often only a wrapper around one container.
Nearly everything in Kubernetes is an object. Objects are persistent entities within the Kubernetes system.

A Pod is one of the most primitive objects Kubernetes can handle and is a fundamental building block. It is used by many other more advanced objects.
A Pod can also contain so-called init-containers. Those containers are run before the actual containers of the Pod are started, and are then shut down again.

One of the most common use-cases for an init-container is waiting for required resources to become available.
Many micro services need some sort of connection to a database. That logic can be put into an init-container which polls for a database to be available.

If the database is available, the init-container shuts down successfully and the actual container can start.

2️⃣ Why do we need Pods?

As we've already learned, a Pod is a fundamental building block of Kubernetes which doesn't handle raw containers but instead takes a container and always wraps it with a Pod.
This design actually has certain advantages. Even if a Pod does only contain one container, it can be seen as an abstraction that can in return be implemented in several ways.
Why? Well, Kubernetes supports multiple runtimes.

There are runtimes that support Pods themselves, and there are others which don't. No matter what runtime you use, all you see is Pods, and the underlying implementation is basically hidden from you.
The other advantage is that there's always a Pod. Not a Container (A SingleContainerPod) and a Pod (a MultiContainerPod). The amount of containers running doesn't matter anymore, as only Pod handling needs to be implemented by Kubernetes.
And on a user-level, this also is advantageous. All you need to deploy is a Pod. You don't need to deploy a container if there's only one, and a Pod if there are multiple containers. This makes the handling easier for you, and that's a great thing for developer experience!

3️⃣ Creation of a Pod

As long as you have a container at hand, which is pushed to a registry, that your cluster can reach, you're good to go.

You can take a look at the Pod example spec shown below to get an idea of how it looks. apiVersion: v1 kind: Pod metadata:   name: example-app   lab
You could send this spec off to your Kubernetes cluster by calling

kubectl apply -f pod.yaml

and Kubernetes would immediately start with its work.

The control plane components will first take the spec and save it to the object storage (etcd).
Another component will then process the spec and check if it already has the image at hand. If not, it will pull it from the registry, and then deploy the Pod to the cluster.

After that a kubelet on a certain node, which is selected based on information like the ...
... resources available and more, is instructed to deploy the Pod and with that the container associated with it.

Three seconds after the Pod was actually started, Kubernetes will try to check if the Pod is actually ready.
After three seconds a HTTP GET request is sent to the HTTP endpoint specified within your Pod template, and on receiving a successful HTTP status code, the Pod will be reported to be alive.

Then finally, your Pod is running and ready to be used!
Every three seconds, Kubernetes will check in with the same endpoint to see if the Pod is still alive. If that request ever fails, Kubernetes will consider the Pod dead, kill it, and then restart it again.

4️⃣ Should you use Pods?

That's an interesting question! You can, of course, use Pods to deploy your applications, but you shouldn't.

Although you can tell Kubernetes to deploy a "raw pod", there are more advanced objects like Deployments, Jobs, or DaemonSets, ...
... which offer way more functionality than a basic Pod. And they all use Pods under the hood, next to their advanced functionality.

It's good to know what a Pod is, and how to use it, but in the end, you'll mostly work with other objects.
See a Pod as the fundamental building block that it is, and play around with it a little to get used to what you can do with it.

But other than that, if you ever think about deploying something to production, better take a look at more advanced workflow objects.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Oliver Jumpertz

Oliver Jumpertz Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @oliverjumpertz

12 Dec
Kubernetes vs Serverless offerings

Why would you need Kubernetes when there are offerings like Vercel, Netlify, or AWS Lambda/Amplify that basically manage everything for you and offer even more?

Well, let's try to look at both approaches and draw our own conclusions!

🧵⏬
1️⃣ A quick look at Kubernetes

Kubernetes is a container orchestrator and thus needs containers to begin with. It's a paradigm shift to more traditional software development, where components are developed, and then deployed to bare metal machines or VMs.
There are additional steps now: Making sure your application is suited to be containerized (12-factor apps, I look at you: 12factor.net), containerizing the application, following some pretty well-proven standards, and then pushing the image to a registry.
Read 35 tweets
11 Dec
A gentle introduction to Kubernetes (short: K8s)

You might have heard the name Kubernetes already and can't really imagine what it is, or you've already heard about it but still need a little more info.

No matter what your background is, this thread is for you!

🧵⏬
1️⃣ What is Kubernetes?

Kubernetes is an open source container orchestration platform. It basically handles everything related to deploying, managing and scaling containerized applications.

Its name originates from Greek, meaning something like pilot.
You might have already worked with Docker and created a few containers, started them, and then used it to deploy a database to test your app locally.

And now imagine that you want to take your app, containerize it, and deploy it to a server.
Read 25 tweets
27 Nov
DI - Dependency Injection

Dependency injection is a technique in which an object receives other objects it depends on.

It is actually one form of the broader technique inversion of control.

🧵👇🏻
1⃣ What is it?

Dependency injection is a technique where every other object (service) an object (client) depends on is injected from the outside.

So instead of simply instantiating everything on its own, a class relies on it being passed in from the outside.
You can also view it this way:

Imagine your favorite RPG character could only wear the equipment they started with. No way to change the equipment or the look of your character's equipment from the outside.

Would be boring and inflexible, wouldn't it?
Read 13 tweets
26 Nov
The Singleton Pattern

The singleton pattern is a software design pattern.

You can also call it the Highlander Principle: There can only be one!

But don't expect epic fights with swords and beheadings, that's only for the movie(s).

🧵👇🏻
1⃣ What is it?

As stated before, the singleton pattern is a software design pattern.

It restricts the instantiation of a class or a certain object to a single instance.

The pattern and its name are actually derived from the mathematical concept of a singleton.
In other words:

If you have a class A and make it a singleton, there can only be exactly none or exactly one instance per application.

Why none?

Because sometimes those singletons are also instantiated lazily to save resources, in case they are never needed!

👇🏻
Read 10 tweets
25 Nov
The Proxy pattern

The proxy pattern is a software design pattern.

It is basically, in its simplest form, an interface to something else.

But let's take a look at what it is and how you could use it!

🧵👇🏻
1⃣ What is it?

A Proxy is a wrapper (object), that wraps another object.

Imagine it like a container that looks exactly like the object it wraps, behaves nearly the same, but may add some additional functionality.

You can imagine it, visually, like shown below.
If you need another example:

Imagine a wetsuit. It's a thin layer above your body, keeps the shape of your body, but adds the ability to keep you dry inside!

👇🏻
Read 10 tweets
24 Nov
The Iterator Pattern

The iterator pattern is a design pattern which can be used to decouple algorithms from containers.

Let's take a look into what it actually is, how to apply it, and which problems it solves!

🧵👇
1⃣ What problems does it solve?

✅ The elements of an aggregate object should be accessed and traversed without exposing its representation (underlying data structure)

✅ New traversal operations should be defined for an aggregate object without changing its interface
Those two points may sound a little complicated, but you can view it this way:

If you define access and traversal operations within an object's interface (its methods viewable and usable from the outside), it becomes inflexible.
Read 14 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!