1. Docker and Kubernetes
After the recap about modern software design, let us dig deeper into the relationship between Docker and Kubernetes.
2. Container Orchestration Tools
Remember: these days, typical software stacks consist of many individual containers. Numbers can reach up to tens, hundreds, sometimes thousands of individual containers.
Now, managing all these containers is known as "container orchestration". Nowadays, we can choose from many container orchestration tools,
like Docker Compose, Docker Swarm, Apache Mesos, HashiCorp's Nomad, and, of course, Kubernetes.
Kubernetes has gained a lot of popularity in recent years, and it dominates the market right now. There are many reasons for this, and we will learn about this in a second, but let us mention a primary reason right now:
Kubernetes is available for all important environments. You can use it in any cloud, but also on-prem, or even in hybrid scenarios. That makes it an excellent solution for deploying your software.
3. Kubernetes for Orchestration
So why has Kubernetes gained so much popularity?
Well, it makes solving the typical challenges of container orchestration relatively easy.
These challenges are: when to deploy your containers and on which physical
hardware, how to enable networking for container communication,
what to do when a container stops working, how to make sure that your containers are started and stopped in the right order, or how to attach storage.
To solve all those challenges, Kubernetes interacts with so-called "Container Engines" that live on each computer you want to run your containers on. Kubernetes tells the container engines to start or stop your containers in the correct order and in the right place.
You will learn a lot more about this architecture in the next lesson.
4. The Relationship between Docker and Kubernetes
Docker is indeed the container engine of choice in many cases. Kubernetes interacts with Docker as the container engine and
will instruct it to start or stop your containers.
We typically use Docker to create and update Docker images,
and to create containers from these images.
Kubernetes will never create Docker images for you; that is the job of Docker.
Kubernetes is an application on top of Docker that orchestrates all your containers.
5. Kubernetes Manifests
Before getting deeper into the architecture of Kubernetes, let's get a little more interactive with the next exercise. To prepare that let's talk about how we interact with Kubernetes, especially how we use the command line tool "kubectl".
One way to define the containers we want to run on Kubernetes are Manifests.
These are YAML files which describe the containers you want, how to configure them, where they should run, and a lot more.
On the left you can see an example of such a Manifest. Don't worry, we will get into the details later.
These Manifests are declarative, which means you describe what you want, or
on other words the state you want to achieve.
They are not imperative, you do not describe how to achieve that state.
6. kubectl
We will learn a lot more about the architecture of Kubernetes later on,
but let us introduce "kubectl" already here. "kubectl" is a command line tool to interact with Kubernetes that comes with many commands and options.
It reaches out to the Kubernetes API, sends our Manifests to Kubernetes, and Kubernetes will then compute what to do in order to achieve the state we want.
7. Let's practice!
With all that knowledge gained so far, let's practice.