Microservices, Docker and Kubernetes concepts for the Absolute Beginners.
In this article, I will try to explain; What Microservices are, What Docker is, What Kubernetes is, and Why they are used,
Table of contents
#LikeIm5eries.
Introduction.
For an absolute beginner, understanding what microservices are, the role that Docker plays and what Kubernetes is, might be a problem. Lots of Articles do not do justice to these concepts for 3 main reasons.
- Lots of Technical Jargon,
- Abstract concepts. Most article writers do not relate these topics to the day-to-day examples that almost anyone can relate with.
- Most articles do not explain why developers use these tools, and why they are very important in the industry. This article is a starting point article to help beginners have a holistic idea of what these things are, so they can take their research from there.
Microservices?
Microservices are like the hottest thing in the DevOps and deployment world right now. And a lot of companies are adopting microservices architecture as the mode of shipping their application.
To understand microservices, we need to have a basic idea of Application Architecture. For simplicity, let's take an e-commerce web application as an example, almost anyone can access an e-commerce website like Amazon to buy the things they need or want.
So how is an application like Amazon architected? An e-commerce website will have a frontend, (The things you can see on your laptop or phone), the Backend(The part of the computer that you don't see, but carries out the logic to make things happen when you click on the website), the database (the part of the website that stores information), the authentication layer (part of the website that lets you log in to the ecommerce website securely) Payment gateways (the part that lets you pay for your goods online with your card securely) etc.
Before the rise of Microservices, all these features will be built as one monolithic and rigid application; as an application developer, you would have to build all those aspects of your application from scratch into a giant meatball. All the code of the application would be written as a single source program. This created some problems.
It was difficult to add new features and updates to the application, because a simple feature update to the database for example can cause the app to malfunction.
When the app develops a problem, it's very difficult to identify the source of the problem.
The application developer is confined to using one language in building the whole of his application.
Here comes microservices. Microservices are simply the act of developing different parts of your application as separate, independent services. And getting them to communicate by way of HTTP protocols or other protocols. In a microservices' architecture, responsibilities of your application are divided between smaller services that only focus on specific tasks. These services can then communicate among themselves to obtain the information they need to produce results.
The idea is that the frontend will be developed separately as a standalone service, the payment gateway will be developed as a separate service, the backend will also be developed as a separate service which all communicate together to create complex desired actions. This has some advantages.
Updates can easily be added to your applications without breaking the whole application. For example, updating the backend will not have any effect on other parts of the application, like the database.
You can use different programming languages to develop different parts of your applications. For example, a programming language like Golang, is very ideal for the backend due to its speed.
Whenever anything goes wrong, it's very easy to identify the source of the problems.
It helps in dividing up applications, so that members of a team can work on different parts of the application simultaneously.
Due to its advantages, software companies started adopting microservices as the mode of developing their applications.
For Microservices to be implemented, there needs to be containerization.
Docker?
There comes in docker. The docker brings the containerization game to the table. As stated earlier, microservices are all about breaking down our applications into smaller independent units, however for the purpose of deployment, they need to be packaged in a runnable manner. This act of packaging is referred to as containerization.
Containerization is the act of packaging software code and all it needs to run in an isolated unit, called a container, which can run consistently in any server.
Docker is simply a service that helps you package your applications and its dependencies as small isolated container units which can be run on any cloud platform. While microservices can be regarded as an application deployment pattern, containers like docker help you to implement the microservices pattern.
The idea of docker is to create lightweight machines on top of host operating systems. Docker abstracts away the host operating system, sits on it and help you isolate your containerized applications so that it can run independently. The primary effect of docker is faster boot times for our applications.
An image depicting this architecture is shown below.
Kubernetes?
You may then ask, what is the role of Kubernetes, then? The developer's community generally defines Kubernetes to be an ORCHESTRATOR. I would simply define Kubernetes to be an automated container controller.
As your application grows, you get more users, and you add more features, consequently, your application becomes complex and doing some things manually would definitely become a nightmare.
For example, docker containers are ephemeral, i.e. they can go off anytime. If the Docker container that contains your payment gateway service, for example, goes off, the effect is that people relying on your services, would not be able to pay for your services. This can translate to loss of revenue to your business.
Remember, I said earlier that microservices communicate with each other; containers identify other containers by way of IPs. If a Docker container should go down, Docker will automatically replace the dead container with a new container containing your application, but with a new IP.
The effect of this is that existing containers would not be able to communicate with the new container, as they don't know the new container's IP address. Which means although there is a new container, since the other pre-existing containers cannot communicate with the new container, the new container is as good as dead.
To solve this problem, you as the container administrator will have to go to each container and basically tell them the IP address of the new container. Now, if you are in charge of 100 containers, which is quite common to most medium-sized businesses, you would have to go to each and every single container, making the same repetitive, boring and time-consuming configurations, just to let your containers talk to each other and get them back to work.
Kubernetes was basically created to solve this type of problem and many more. Your Docker container would sit inside your Kubernetes cluster, which would then attach a fixed address to your containers, this fixed address is called service. All your containers will communicate through the fixed service channel, and not through their IP. The resultant effect is that while your docker containers may be ephemeral and may shut down at some point, Kubernetes will help you to automatically restart a new and fresh container without the manual configuration
This scenario explained above constitute just one of the many things that Kubernetes offers. Kubernetes can simply be regarded as an automated container controller which helps in the automation process of the so many of the containerized cloud deployments.
As stated earlier, this article is not a deep dive, rather it is directed at the absolute non-tech beginners who are looking to transition into tech. Docker and Kubernetes are really wide and technical tools, but having a holistic idea of what these tools will definitely aid a beginner's learning process.
Tolulope Olusegun