Docker and Kubernetes

Docker and Kubernetes

Introduction

Docker is set of platform as a service (PAAS) to deliver software systems containerized. According to Wikipedia “Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. The service has both free and premium tiers. The software that hosts the containers is called Docker Engine. It was first started in 2013 and is developed by Docker, Inc”

Docker inc, the company

In asp.net core, the dependency injection (DI) and inversion of control (IoC) are implemented by default within the framework.

Docker, the technology

Docker the technology Dock worker -> running business applications inside containers, it is simple and it can be scaled.
If a new team member joined the team and wants to work with current company projects. Using docker in such a case can be super easy, You can just push the image/container that contains the system and the newcomers can just pull it.
– Containers can help in scaling up and down the applications smoothly, it helps in fast deployment and rollbacks if needed. Containers help in monitoring the applications and deploy easily to different environments (staging, production). All the previous benefits can be reflected easily in reducing the system cost.

Docker Compose

The docker-compose is a container orchestration tool, it enables us to define, share and configure multi-containers applications. Docker file enables us to run an independent container for an application, for ex: a frontend application or a backend application. Docker-compose can smoothly integrate the system applications and it will be easier with one command to make the whole system parts up and running.

Docker Compose

Docker compose

Kubernetes (K8s)

Kubernetes manage applications when the applications go to scale. Google built borg and omega systems. then Kubernetes is from google (k8s), and the helmsman is the person who steers the ship. Kubernetes is open source and like most open-source applications, it is hosted on Github. Kubernetes definition at its GitHub repo definition is as follows, “Kubernetes also known as K8s, is an open-source system for managing containerized applications across multiple hosts. It provides basic mechanisms for deployment, maintenance, and scaling of applications.”

Docker provides the mechanics for starting and stopping containers, Docker cares about low-level staff. Kubernetes doesn’t care about low-level staff.

Kubernetes cares about the high-level staff, such as how many containers to run and on which nodes. One important thing, Kubernetes is care about is the how-to scale the applications without downtime.

Kubernetes is the commandant, K8S is fighting for you, which means if a node from your cluster has a problem or a failure, K8S shut down this node. In case the node is not in use anymore K8S shuts down this machine also and frees resources. As it is illustrated in the below images, Kubernetes can manage the containers’ scale up and down smoothly.

Kubernetes scale up

Kubernetes scale-up

Kubernetes scale down

Kubernetes scale down

Demo

I created two projects to test the docker and how it works. In beginning I created a backend application using nodejs with a very simple controller and to make it robust, I add some logic, i.e. a controller that calls a service that returns dummy data. In the frontend, I created a simple angular application. With every one of the backend and frontend applications, you will find a dockerfile for applications containerization. The third folder is a folder with the name “nginx”, which contains the webserver configurations. At the root folder, I created a compose file that will help to up and run the projects together in one step. When you will run the command “docker-compose up”, your containers will start to up one by one as in the following image where the first container which is Postgres container will up and then the client and the server containers will up and run one by one.

Docker Compose Up

Docker-compose up

Finally using postman or swagger, you can find the results below,

Docker Compose Up Client

Conclusion

Docker is a project that enables developers, and architects to deliver projects as an agnostic system that can be packaged into containers. In this post, I tried to describe what is the docker, the technology, and the company. With providing a brief on how to create and use dockerfile dockerignore and docker-compose files. In the post, you can find a demo for a simple project containing frontend and backend layers and how those layers can be up and run with simple steps.

You can find the project source code at github

Enjoy…!!!

I can help you to build such as software tools/snippets, you contact me from here

 

Leave a Reply

Your email address will not be published. Required fields are marked *