You are on page 1of 17

Docker & Kubernetes

The why and what


What and why?
Purpose of Docker: Its primary focus is to automate the deployment of
applications inside software containers and the automation of operating
system level virtualization on Linux. It's more lightweight than standard
Containers and boots up in seconds.Build and run your application
,libraries ,dependencies in one whole package.

Difference between docker and vm:


In Docker, the containers running share the host OS kernel. A Virtual
Machine, on the other hand, is not based on container technology. They are
made up of user space plus kernel space of an operating system. Under VMs,
server hardware is virtualized.

Although Docker takes in minimal image files to run ,while vm loads up an


entire operating system.
Who uses Docker?
Docker is widely used in software and it industry .some of the companies that
use it are :

JPMorgan Chase, ThoughtWorks, Inc., Docker, Inc., Neudesic


Why? Some of the popular images that are used by docker are:
Nginx, Redis,Postgres,elastic search ,mongo ,my sql and finally RabbitMQ
They do not need much gui application and needs only service in
background ..
Docker can run them in one click and additionally gives the container its
security and isolation than over running it as an executable separately.
Build An Image
Dockerfile What is an Image? Example

Company
Docker can build images Docker Image is a read-only We can have a base image
automatically by reading the template to build containers. of ubuntu for base OS and
instructions from a Dockerfile. A An image holds all the
have our Node application
Dockerfile is a text document that information needed to bootstrap
contains all the commands a user a container, Configured in a Dockerfile
could call on the command line to including what processes to run .Now building this file will
assemble an image. Using docker and create an image and running
build users can create an the configuration data. this will add a new layer
automated build that executes Every image starts from a (this is your project+base
several command-line base image, and a template is
image ) .This new layer is
instructions in succession. created by using the instructions
that are stored in the DockerFiIe. considered a different
version of your Base image.
How to run?
Utilize its mapped
Build an image Run the container
commands

Build an image from Use docker commands Use its functionailities:


Dockerfile to start a container -like running node app.js
based on that image ..
-docker image build .
-docker container run –p -docker nginx-server –it
=build image using 80:80 –name=nginx- node app
current directory server nginx:latest
dockerfile
Screenshots:
Kubernetes
What's Kubernetes?

• Kubenetes(K8S) is an open source tool for


managing containerised workloads.Built on top of docker.

• It operates at the container level


level to automate the deployment, scaling
and management of applications.

• K8S works alongside a containerisation tool,


like Docker.

• Popular Container Orchestrator

• Run anywhere(needs docker runtime)


Why?
It’s not enough to run containers
you need to be able to:

• Integrate and orchestrate these modular parts

• Scale up and scale down based on the demand

• Make them fault tolerant

• Provide communication across a cluster


Features of Kubernetes
• Horizontal Scaling :Run multiple instances of application

• Self Healing :Auto Restart of application of failure and tries to fix some basic errors

• Automated Rollouts

• Various other features like Service Discovery and load balancing etc.

• Easily Compatible

• simple to maintain and configure

• Isolation
Orchestrator?
Container Orchestration refers to the automated arrangement, coordination, and management of
software containers.

If you have an application which you can manage alone and sufficient –You’re good!
But what if your application is deployed on large scale basis?

We need to run your “monolithic “ application for requests and this is a bad practice.
So we split it up into mini chunks of modules working separately..

These are called microservices


Orchestrator Contd.
But we have some challenges to microservices:
• Service Discovery – Route discovery

• Load Balancing - Balancing server load among instances

• Secrets/configuration/storage management

• Health checks

• Auto-[scaling/restart/healing] of containers and nodes

• Zero-downtime deploys – high performance

This is where container orchestration platforms become extremely useful and


powerful, because they offer a solution for most of those challenges.
Cluster overview in K8s Orchestration happens here ..

Master manages the workers state.


It can replicate ,expose or heal the
workers.

Slaves or workers manage the


application functionality ,storage spaces
etc.

The application will always be available


even if one node fails and even if all fail
it ll just create one more and heal the
failed ones in the mean time.
Then it deletes the extra node for
processing efficiency.
Kubernetes Core Concepts

• Master node: Runs multiple controllers that are responsible for the health of the cluster, replication,
scheduling, endpoints ,Kubernetes API.Generally it makes sure everything is running as it should be
and looks after worker nodes.

• Worker node : Runs the Kubernetes agent that is responsible for running Pod containers via Docker or
rkt, requests secrets or configurations, mounts required Pod volumes, does health checks and reports
the status of Pods and the node to the rest of the system.

• Pod: The smallest and simplest unit in the Kubernetes object model that you can create or deploy. It
represents a running process in the cluster. Can contain one or multiple containers.

• Deployment: Provides declarative updates for Pods (like the template for the Pods), for example the
Docker image(s) to use, environment variables, how many Pod replicas to run, labels, node selectors,
volumes etc.

• ReplicaSet: Controller that ensures a specified number of Pod replicas (defined in the Deployment) is
running at any given time.

• Service: An abstraction which defines a logical set of Pods and a policy by which to access them
.Generally it’s used to expose Pods to other services within the Cluster.
Swarm-Raft Consensus Algorithm
Suppose we have 5 container instances
running on different virtual ports
Depending on server availability ,it will
ping all other nodes upon its expiry time.
If any server is found available
application Is given to that node and the
current node becomes master.

Master manages
rolling,scheduling,scaling etc. of slaves

The rest are slaves


Slaves manage application..

This is master slave architecture.


Screenshots
mx growth

Thank You

You might also like