Docker & Kubernetes
Tags: ibbus, k8sfull, dockerfull, orchestration
Published: 2024-01-18 07:46:34

## **Docker**
A container is like a compact box holding an application’s dependencies all in one place. This not only allows an application to run quickly  but also makes it portable and easy to transfer from one environment to another.

Docker Swarm is Docker’s native open-source container orchestration solution and an alternative to Kubernetes. 

It offers scaling, multi-host networking, automatic load balancing, and all other features required for mass container deployment and administration without depending on a third-party orchestration tool. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ys5rsrvspsdh2s9b8smm.png)

It has a straightforward installation process, is lightweight, and is easy to integrate if you’re already accustomed to the Docker ecosystem.

The core component of Docker is Docker Engine, which hosts its containers. Docker Engine runs on the host OS and interacts with containers to access system resources. 

Docker also uses YAML configuration files that specify how to build a container and what runs inside it. This is one reason why Docker is portable and easy to troubleshoot.

Docker Swarm is a great option when working with a few nodes and relatively simple applications. However, if you’re orchestrating large nodes for critical applications, you would benefit more from Kubernetes’s security features, constant monitoring, flexibility, and resilience.

## **Kubernetes provides**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/if9chmmfaq00hv5cmrms.png)

**Compute scheduling**: It considers the resource needs of your containers, to find the right place to run them automatically.

**Self-healing**: If a container crashes, a new one will be created to replace it.

**Horizontal scaling**: By observing CPU or custom metrics, Kubernetes can add and remove instances as needed.
Volume management—It manages the persistent storage used by your applications.

**Service discovery & load balancing**: IP address, DNS, and multiple instances are load-balanced.

**Automated rollouts & rollbacks**: During updates, the health of your new instances are monitored, and if a failure occurs, it can roll back to the previous version automatically.
Secret & configuration management. It manages application configuration and secrets.

Kubernetes uses a master/slave communication model where there is at least one master and usually several worker nodes.

**API server**: Exposes the Kubernetes API for controlling the cluster

**Controller manager**: Responsible for watching the cluster’s objects and resources and ensuring the desired state is consistent.

**Scheduler**: Responsible for scheduling compute requests on the cluster.

**etcd**: An open-source distributed key value store used to hold the cluster data.

The worker nodes provide the container runtime for your applications and have a few components responsible for communicating with the master and networking on every worker node.

**Kubelet**: Responsible for communicating to the master and ensuring the containers are running on the node.

**Kube-proxy**: Enables the cluster to forward traffic to executing containers.

**Docker (container runtime)**: Provides the runtime environment for containers.

To run an application on Kubernetes, you need to communicate with the API server using the object model.

**Pod**: A group of one or more containers and metadata.

**Service**: Works with a set of pods and directs traffic to them.

**Deployment**: Ensures the desired state and scale are maintained.