Professional Documents
Culture Documents
Kubernetes PDF
Kubernetes PDF
© Study9
LXC Technology Stack
History of
Containerization
So what is new?
Event Driven
DCOS
Architectures
Microservices
© Study9
Divide and Conquer
Challenges in Monolithic Architecture
• Developer coordination due to developer inter dependency
• Large code overloading IDE runtime – impacting developer
productivity
• Nobody knows impact of refactoring - so even if alternative
technology stack /language can provide clear benefits, people are
hesitant to adopt and refactor
• One component fails and the whole app goes down
• Scaling such a monolithic application can only be accomplished by
deploying the same EAR/WAR packages in more servers – also
known as horizontal scaling. Each copy of the application in
various servers will utilize the same amount of underlying
resources.
Scale Cube
Scaling by splitting different things
Benefits
• Each microservice is relatively small
• Easier for a developer to understand
• The IDE is faster making developers more productive
• The web container starts faster, which makes developers more productive,
and speeds up deployments
• Each service can be deployed independently of other services - easier to
deploy new versions of services frequently
• Easier to scale development. It enables you to organize the development
effort around multiple teams. Each team can develop, deploy and scale their
service independently of all of the other teams.
• Improved fault isolation. For example, if there is a memory leak in one service
then only that service will be affected. The other services will continue to
handle requests. In comparison, one misbehaving component of a monolithic
architecture can bring down the entire system.
• Each service can be developed and deployed independently
• Eliminates any long-term commitment to a technology stack
How to implement MicroServices
• Step 1: Decide on a application division strategy
• Step 2: Decide on a team division strategy
• Step 3: Have clear documented approach of service interactions
and choice of interaction method –
• Request/Response
• Event Driven with Queues (Kafka)
• Step 4: Choose and implement hosting strategy
• Container
• VM
• Bare-metal (performance focused)
Best Practices
• Design for one service per container
• Implement a service discovery solution – Dont use IP
• Etcd
• Consul
• Zookeeper
• Distribute shared assets via CDN – Shared Storage for Static Data
such as MIME
• Implement API Gateway
• Database hosting should be done outside of container
orchestration layer and preferably in a DBaaS way
Drawbacks
• Developers must deal with the additional complexity of creating a
distributed system.
• Developer tools/IDEs are oriented on building monolithic applications
and don’t provide explicit support for developing distributed
applications.
• Testing is more difficult
• Developers must implement the inter-service communication
mechanism.
• Implementing use cases that span multiple services requires careful
coordination between the teams
• Deployment complexity. In production, there is also the operational
complexity of deploying and managing a system comprised of many
different service types.
Why Docker is a Great Fit?
• Single process bundled with libs and bins required to run
• Docker is portable and can move across multiple systems ensuring HA
• Docker is fast to provision
• Docker can quickly come up, do a job and immediately remove itself
• Scaling is fast
• Using kubernetes logical service grouping, the individual app failure is
not impacting end user experience
Companies who have adopted
• Netflix, eBay, Amazon, the UK Government Digital Service,
realestate.com.au, Forward, Twitter, PayPal, Gilt, Bluemix, Soundcloud,
The Guardian, and many other large-scale websites and applications
have all evolved from monolithic to microservices architecture
• Netflix has a widespread architecture that has evolved from monolithic
to SOA. It receives more than one billion calls every day, from more
than 800 different types of devices, to its streaming-video API. Each
API call then prompts around five additional calls to the backend
service.
• Amazon has also migrated to microservices. They get countless calls
from a variety of applications—including applications that manage the
web service API as well as the website itself—which would have been
simply impossible for their old, two-tiered architecture to handle.
• The auction site eBay is yet another example that has gone through the
same transition. Their core application comprises several autonomous
applications, with each one executing the business logic for different
function areas
Docker
© Study9
What is container
■ It is a lightweight alternative to virtualization in Linux
■ In the same lines of solaris zones and BSD jails
■ The idea is to divide the shell into multiple pieces each behaving as an
independent operating system environments
■ Essentially it builds on the logic of chroot folders in which case the
contents of the folder would think of that folder as the whole
operating system.
■ Containers can have different shells while have a common kernel
What is a docker
■ Docker is not actually a container but kind of a management api for
managing linux containers which are called LXC
■ However, docker adds some really interesting abilities to the LXC,
making it quite unique in behavior.
■ Docker makes containers portable across systems that can run the
docker environment. So that a Ubuntu os will run on a CentOS.
Ubuntu and CentOS will share the kernel but have different shells.
And an application running inside Ubuntu docker container will think
as if it is running on a complete Ubuntu
■ Docker as a technology has been very popular as the chosen
containerization technology
■ The docker containers are heavily used in microservices architectures
Docker
Relevance in DevOps
Docker Commands
Using Docker
• sudo curl -sSL https://get.docker.com/ | sh
• docker pull nginx
• docker run --name docker-nginx -p 80:80 -d nginx
• docker exec -i -t docker-nginx2 /bin/bash
• docker ps
• lynx localhost:80
Benefits of Docker
– # yum update -y
– # yum install -y httpd
– # exit
– # docker ps -a
– # docker commit c16378f943fe fedora-httpd
– Check that this worked by running:
– # docker images
– You should see both fedora-httpd and fedora listed.
Creating Docker Image: Docker Commit
■ Taking a SnapShot and Creating Docker Images from it
– # docker run -i -t fedora bash
– This has created a running Fedora instance in a Docker container and attached a
bash shell to the tty. Inside the container shell, run the following yum
– commands to get the latest updates for Fedora, and to install Apache httpd:
– # yum update -y
– # yum install -y httpd
– # exit
– # docker ps -a
– # docker commit c16378f943fe fedora-httpd
– Check that this worked by running:
– # docker images
– You should see both fedora-httpd and fedora listed.
Creating Docker Image: Dockerfile
■ nano Dockerfile
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y apache2 && apt-get clean && rm -rf
/var/lib/apt/lists/*
EXPOSE 80