SlideShare a Scribd company logo
1 of 133
Download to read offline
Dockers and Kubernetes
A way to build scalable and portable applications with Cloud
Dr Ganesh Neelakanta Iyer
Amrita Vishwa Vidyapeetham, Coimbatore
Associate Professor, Dept of Computer Science and Engg
About Me • Associate Professor, Amrita Vishwa Vidyapeetham
• Masters & PhD from National University of Singapore (NUS)
• Several years in Industry/Academia
• Sasken Communications, NXP Semiconductors, Progress
Software, IIIT-HYD, NUS (Singapore)
• Architect, Manager, Technology Evangelist, Visiting Faculty
• Talks/workshops in USA, Europe, Australia, Asia
• Cloud/Edge Computing, IoT, Game Theory, Software QA
• Kathakali Artist, Composer, Speaker, Traveler, Photographer
GANESHNIYER http://ganeshniyer.com
Outline
• Dockers
• Need for Orchestration
• Kubernetes
How many worked on Kubernetes?
Dr Ganesh Neelakanta Iyer 4
How many of you have worked on
Dockers?
Dr Ganesh Neelakanta Iyer 5
How many of you have heard of dockers?
How many know what is Cloud Computing?
Dockers
Flashback –
Lets go back to pre-1960’s
Multiplicityof
Goods
Multiplicityof
methodsfor
transporting/storing
DoIworryabout
howgoodsinteract
(e.g.coffeebeans
nexttospices)
CanItransport
quicklyandsmoothly
(e.g.fromboatto
traintotruck)
Cargo Transport Pre-1960
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
Also an M x N Matrix
Multiplicityof
Goods
Multiplicityof
methodsfor
transporting/storing
DoIworryabout
howgoodsinteract
(e.g.coffeebeans
nexttospices)
CanItransport
quicklyand
smoothly
(e.g.fromboatto
traintotruck)
Solution: Intermodal Shipping Container
…in between, can be loaded and
unloaded, stacked, transported
efficiently over long distances,
and transferred from one mode
of transport to another
A standard container that is
loaded with virtually any
goods, and stays sealed until
it reaches final delivery.
This eliminated the M x N problem…
and spawned an Intermodal Shipping Container Ecosystem
• 90% of all cargo now shipped in a standard container
• Order of magnitude reduction in cost and time to load and unload ships
• Massive reduction in losses due to theft or damage
• Huge reduction in freight cost as percent of final goods (from >25% to <3%) massive globalizations
• 5000 ships deliver 200M containers per year
Static website
Web frontend
User DB
Queue Analytics DB
Background workers
API endpoint
nginx 1.5 + modsecurity + openssl + bootstrap 2
postgresql + pgv8 + v8
hadoop + hive + thrift + OpenJDK
Ruby + Rails + sass + Unicorn
Redis + redis-sentinel
Python 3.0 + celery + pyredis + libcurl + ffmpeg + libopencv + nodejs +
phantomjs
Python 2.7 + Flask + pyredis + celery + psycopg + postgresql-client
Development VM
QA server
Public Cloud
Disaster recovery
Contributor’s laptop
Production Servers
The Challenge
Multiplicityof
Stacks
Multiplicityof
hardware
environments
Production Cluster
Customer Data Center
Doservicesand
appsinteract
appropriately?
CanImigrate
smoothlyand
quickly?
Results in M x N compatibility nightmare
Static website
Web frontend
Background workers
User DB
Analytics DB
Queue
Development
VM
QA Server
Single Prod
Server
Onsite Cluster Public Cloud
Contributor’s
laptop
Customer
Servers
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
Static website Web frontendUser DB Queue Analytics DB
Development
VM
QA server Public Cloud Contributor’s
laptop
Docker is a shipping container system for
code
Multiplicityof
Stacks
Multiplicityof
hardware
environments
Production Cluster
Customer Data
Center
Doservicesand
appsinteract
appropriately?
CanImigrate
smoothlyand
quickly
…that can be manipulated using
standard operations and run
consistently on virtually any
hardware platform
An engine that enables any
payload to be encapsulated
as a lightweight, portable,
self-sufficient container…
Static website Web frontendUser DB Queue Analytics DB
Development
VM
QA server Public Cloud Contributor’s
laptop
Or…put more simply
Multiplicityof
Stacks
Multiplicityof
hardware
environments
Production Cluster
Customer Data
Center
Doservicesand
appsinteract
appropriately?
CanImigrate
smoothlyand
quickly
Operator: Configure Once, Run
Anything
Developer: Build Once, Run
Anywhere (Finally)
Static website
Web frontend
Background workers
User DB
Analytics DB
Queue
Development
VM
QA Server
Single Prod
Server
Onsite Cluster Public Cloud
Contributor’s
laptop
Customer
Servers
Docker solves the M x N problem
Docker containers
• Wrap up a piece of software in a
complete file system that contains
everything it needs to run:
– Code, runtime, system tools, system
libraries
– Anything you can install on a server
• This guarantees that it will always
run the same, regardless of the
environment it is running in
Why containers matter
Physical Containers Docker
Content Agnostic The same container can hold almost
any type of cargo
Can encapsulate any payload and its
dependencies
Hardware Agnostic Standard shape and interface allow
same container to move from ship to
train to semi-truck to warehouse to
crane without being modified or
opened
Using operating system primitives (e.g.
LXC) can run consistently on virtually
any hardware—VMs, bare metal,
openstack, public IAAS, etc.—without
modification
Content Isolation and
Interaction
No worry about anvils crushing
bananas. Containers can be stacked
and shipped together
Resource, network, and content
isolation. Avoids dependency hell
Automation Standard interfaces make it easy to
automate loading, unloading, moving,
etc.
Standard operations to run, start, stop,
commit, search, etc. Perfect for devops:
CI, CD, autoscaling, hybrid clouds
Highly efficient No opening or modification, quick to
move between waypoints
Lightweight, virtually no perf or start-up
penalty, quick to move and manipulate
Separation of duties Shipper worries about inside of box,
carrier worries about outside of box
Developer worries about code. Ops
worries about infrastructure.
Docker containers
Lightweight
• Containers running on
one machine all share
the same OS kernel
• They start instantly
and make more
efficient use of RAM
• Images are
constructed from
layered file systems
• They can share
common files, making
disk usage and image
downloads much
more efficient
Open
• Based on open
standards
• Allowing containers to
run on all major Linux
distributions and
Microsoft OS with
support for every
infrastructure
Secure
• Containers isolate
applications from
each other and the
underlying
infrastructure while
providing an added
layer of protection for
the application
Docker / Containers vs. Virtual Machine
https://www.docker.com/whatisdocker/
Containers have similar resource
isolation and allocation benefits as
VMs but a different architectural
approach allows them to be much
more portable and efficient
Virtual Machines
Virtual machines run guest operating systems—note the OS
layer in each box. This is resource intensive, and the
resulting disk image and application state is an entanglement
of OS settings, system-installed dependencies, OS security
patches, and other easy-to-lose, hard-to-replicate ephemera
Containers vs Virtual Machines
Containers
Containers can share a single kernel, and the only
information that needs to be in a container image is the
executable and its package dependencies, which never need
to be installed on the host system. These processes run like
native processes, and you can manage them individually
Why are Docker containers lightweight?
Bins/
Libs
App
A
Original App
(No OS to take
up space, resources,
or require restart)
AppΔ
Bins
/
App
A
Bins/
Libs
App
A’
Gues
t
OS
Bins/
Libs
Modified App
Union file system allows
us to only save the diffs
Between container A
and container
A’
VMs
Every app, every copy of an
app, and every slight modification
of the app requires a new virtual server
App
A
Guest
OS
Bins/
Libs
Copy of
App
No OS. Can
Share bins/libs
App
A
Guest
OS
Guest
OS
VMs Containers
What are the basics of the Docker system?
Source
Code
Repository
Dockerfile
For
A
Docker Engine
Docker
Container
Image
Registry
Build
Docker Engine
Host 2 OS 2 (Windows / Linux)
Container
A
Container
B
Container
C
ContainerA
Push
Search
Pull
Run
Host 1 OS (Linux)
Changes and Updates
Docker Engine
Docker
Container
Image
Registry
Docker Engine
Push
Update
Bins/
Libs
App
A
AppΔ
Bins
/
Base
Container
Image
Host is now running A’’
Container
Mod A’’
AppΔ
Bins
/
Bins/
Libs
App
A
Bins
/
Bins/
Libs
App
A’’
Host running A wants to upgrade to A’’.
Requests update. Gets only diffs
Container
Mod A’
Easily Share and Collaborate on Applications
• Distribute and share content
– Store, distribute and manage your Docker images in your Docker
Hub with your team
– Image updates, changes and history are automatically shared
across your organization.
• Simply share your application with others
– Ship your containers to others without worrying about different
environment dependencies creating issues with your application.
– Other teams can easily link to or test against your app without
having to learn or worry about how it works.
Docker creates a common framework for developers and sysadmins to work together on distributed
applications
Get Started with Docker
• Install Docker
• Run a software image in a container
• Browse for an image on Docker Hub
• Create your own image and run it in a
container
• Create a Docker Hub account and an
image repository
• Create an image of your own
• Push your image to Docker Hub for
others to use
https://www.docker.com/products/docker
https://www.docker.com/products/docker-toolbox
Docker Container as a Service (CaaS)
Deliver an IT secured and managed application environment for developers to build and deploy
applications in a self service manner
Typical Use cases
App Modernization
Continuous Integration and Deployment (CI / CD)
Microservices
https://mesosphere.com/blog/networking-docker-containers-part-ii-service-discovery-traditional-apps-microservices/
Hybrid Cloud
https://boxboat.com/2016/10/21/maintaining-docker-portability-multi-cloud-world/
How does this help you build better software?
• Stop wasting hours trying to setup developer environments
• Spin up new instances and make copies of production code to run locally
• With Docker, you can easily take copies of your live environment and run on any new
endpoint running Docker.
Accelerate Developer Onboarding
• The isolation capabilities of Docker containers free developers from the worries of using
“approved” language stacks and tooling
• Developers can use the best language and tools for their application service without
worrying about causing conflict issues
Empower Developer Creativity
• By packaging up the application with its configs and dependencies together and shipping
as a container, the application will always work as designed locally, on another machine,
in test or production
• No more worries about having to install the same configs into a different environment
Eliminate Environment Inconsistencies
First Hand Experience
Setting up
• Before we get started, make sure your system has the latest version of
Docker installed.
• Docker is available in two editions: Community Edition
(CE) and Enterprise Edition (EE).
• Docker Community Edition (CE) is ideal for developers and small teams
looking to get started with Docker and experimenting with container-based
apps. Docker CE has two update channels, stable and edge:
– Stable gives you reliable updates every quarter
– Edge gives you new features every month
• Docker Enterprise Edition (EE) is designed for enterprise development
and IT teams who build, ship, and run business critical applications in
production at scale.
Supported Platforms
https://docs.docker.com/install/
In this session, I use Docker for Windows Desktop
Docker for
Windows
If your windows is not in latest version…
https://docs.docker.com/docker-for-windows/release-notes/#docker-community-edition-17062-ce-win27-2017-09-06-stable
Docker for Windows
When the whale in the status
bar stays steady, Docker is
up-and-running, and
accessible from any terminal
window.
Hello-world
• Open command prompt / windows power shell and run
docker run hello-world
▪ Now would also be a good time to make sure you are using
version 1.13 or higher. Run docker --version to check it out.
Building an app the Docker way
• In the past, if you were to start writing a Python app, your first order
of business was to install a Python runtime onto your machine
• But, that creates a situation where the environment on your machine
has to be just so in order for your app to run as expected; ditto for
the server that runs your app
• With Docker, you can just grab a portable Python runtime as an
image, no installation necessary
• Then, your build can include the base Python image right alongside
your app code, ensuring that your app, its dependencies, and the
runtime, all travel together
• These portable images are defined by something called a Dockerfile
Define a container with a Dockerfile
• Dockerfile will define what goes on in the environment
inside your container
• Access to resources like networking interfaces and disk
drives is virtualized inside this environment, which is
isolated from the rest of your system, so you have to map
ports to the outside world, and be specific about what files
you want to “copy in” to that environment
• However, after doing that, you can expect that the build of
your app defined in this Dockerfile will behave exactly
the same wherever it runs
Dockerfile
• Create an empty directory
• Change directories (cd) into the new directory, create a
file called Dockerfile
Dockerfile
• In windows, open notepad, copy the content below, click on Save as, type “Dockerfile”
This Dockerfile refers to a couple of files we
haven’t created yet, namely app.py and
requirements.txt. Let’s create those next.
The app itself
• Create two more files,
requirements.txt and app.py, and
put them in the same folder with the
Dockerfile
• This completes our app, which as you
can see is quite simple
• When the above Dockerfile is built
into an image, app.py and
requirements.txt will be present
because of that Dockerfile’s ADD
command, and the output from app.py
will be accessible over HTTP thanks to
the EXPOSE command.
The App itself
Requirements.txt
app.py
That’s it! You don’t need Python
or anything in
requirements.txt on your
system, nor will building or
running this image install them
on your system. It doesn’t seem
like you’ve really set up an
environment with Python and
Flask, but you have.
Building the app
• We are ready to build the app. Make sure you are still at the
top level of your new directory. Here’s what ls should show
• Now run the build command. This creates a Docker image,
which we’re going to tag using -t so it has a friendly name.
Building the app
• docker build -t friendlyhello .
Where is your built images?
• docker images
Run the app
• Run the app, mapping your machine’s port 4000 to the container’s published port 80
using –p
• docker run -p 4000:80 friendlyhello
• You should see a notice that Python is serving your app at http://0.0.0.0:80.
But that message is coming from inside the container, which doesn’t know you
mapped port 80 of that container to 4000, making the correct URL
http://localhost:4000
• Go to that URL in a web browser to see the display content served up on a web
page, including “Hello World” text, the container ID, and the Redis error message
End the process
• Hit CTRL+C in your terminal to quit
• Now use docker stop to end the process, using the
CONTAINER ID, like so
• Now let’s run the app in the background, in detached mode:
• docker run -d -p 4000:80 friendlyhello
• You get the long container ID for your app and then are kicked back
to your terminal. Your container is running in the background. You
can also see the abbreviated container ID with docker container ls
(and both work interchangeably when running commands):
• docker container ls
Share image
• To demonstrate the portability of what we just created, let’s
upload our built image and run it somewhere else
• After all, you’ll need to learn how to push to registries when you
want to deploy containers to production
• A registry is a collection of repositories, and a repository is a
collection of images—sort of like a GitHub repository, except the
code is already built. An account on a registry can create many
repositories. The docker CLI uses Docker’s public registry by
default
• If you don’t have a Docker account, sign up for one at
cloud.docker.com. Make note of your username.
Login with your docker id
• Log in to the Docker public registry on your local machine.
• docker login
Tag the image
• The notation for associating a local image with a repository on a
registry is username/repository:tag. The tag is optional, but
recommended, since it is the mechanism that registries use to give
Docker images a version. Give the repository and tag meaningful
names for the context, such as get-started:part1. This will put
the image in the get-started repository and tag it as part1.
• Now, put it all together to tag the image. Run docker tag image
with your username, repository, and tag names so that the image will
upload to your desired destination. The syntax of the command is:
Tag the image
Publish the image
• Upload your tagged image to the repository
• docker push username/repository:tag
• Once complete, the results of this upload are publicly available. If you log
in to Docker Hub, you will see the new image there, with its pull
command
Publish the image
• Upload your tagged image to the repository
• docker push username/repository:tag
• Once complete, the results of this upload are publicly available. If
you log in to Docker Hub, you will see the new image there, with its
pull command
Pull and run the image from the remote
repository
• From now on, you can use docker run and run your app on any
machine with this command:
• docker run -p 4000:80 username/repository:tag
• If the image isn’t available locally on the machine, Docker will pull it
from the repository.
• If you don’t specify the :tag portion of these commands, the tag of
:latest will be assumed, both when you build and when you run
images. Docker will use the last version of the image that ran without
a tag specified (not necessarily the most recent image).
No matter where executes, it pulls your image, along with Python and all the dependencies
from , and runs your code. It all travels together in a neat little package, and the host machine
doesn’t have to install anything but Docker to run it.
What have you seen so far?
• Basics of Docker
• How to create your first app in the Docker way
• Building the app
• Run the app
• Sharing and Publishing images
• Pull and run images
The Need for
Orchestration
Systems
The Need for Orchestration Systems
• While Docker provided an open standard for packaging
and distributing containerized applications, there arose a
new problem
– How would all of these containers be coordinated and
scheduled?
– How do all the different containers in your application
communicate with each other?
– How can container instances be scaled?
Dr Ganesh Neelakanta Iyer 72
Solution
Container Orchestration Systems
Dr Ganesh Neelakanta Iyer 73
From Containers to Kubernetes
VM
Host OS
Container
Runtime
Benefits
Isolation
Immutable infrastructure
Portability
Faster deployments
Versioning
Ease of sharing
Challenges
Networking
Deployments
Service Discovery
Auto Scaling
Persisting Data
Logging, Monitoring
Access Control
Kubernetes
Orchestration of cluster of containers
across multiple hosts
• Automatic placements, networking,
deployments, scaling, roll-out/-back, A/B
testing
Docker
Workload Portability
• Abstract from cloud provider specifics
• Multiple container runtimes
Declarative – not procedural
• Declare target state, reconcile to desired state
• Self-healing
Container Scheduler
Container
Kubernetes
• Kubernetes is an open-source container cluster manager
– originally developed by Google, donated to the Cloud Native Computing
Foundation
– schedules & deploys containers onto a cluster of machines
• e.g. ensure that a specified number of instances of an application are running
– provides service discovery, distribution of configuration & secrets, ...
– provides access to persistent storage
• Pod
– smallest deployable unit of compute
– consists of one or more containers that are always co-located, co-
scheduled & run in a shared context
5
Why Kubernetes?
• It can be run anywhere
– on-premises
• bare metal, OpenStack, ...
– public clouds
• Google, Azure, AWS, ...
• Aim is to use Kubernetes as an abstraction layer
– migrate to containerised applications managed by Kubernetes & use only the
Kubernetes API
– can then run out-of-the-box on any Kubernetes cluster
• Avoid vendor lock-in as much as possible by not using any vendor specific APIs
or services
– except where Kubernetes provides an abstraction
• e.g. storage, load balancers
7
Kubernetes Architecture
Dr Ganesh Neelakanta Iyer 77https://www.slideshare.net/janakiramm/kubernetes-architecture
Kubernetes Master
Dr Ganesh Neelakanta Iyer 78https://www.slideshare.net/janakiramm/kubernetes-architecture
kube-apiserver
• The apiserver provides a forward facing REST interface
into the kubernetes control plane and datastore
• All clients, including nodes, users and other applications
interact with kubernetes strictly through the API Server
• It is the true core of Kubernetes acting as the gatekeeper
to the cluster by handling authentication and
authorization, request validation, mutation, and admission
control in addition to being the front-end to the backing
datastore
Dr Ganesh Neelakanta Iyer 79
etcd
• Etcd acts as the cluster datastore
• Providing a strong, consistent and highly available key-
value store used for persisting cluster state
Dr Ganesh Neelakanta Iyer 80
kube-controller-manager
• The controller-manager is the primary daemon that manages all core
component control loops
• It monitors the cluster state via the apiserver and steers the cluster
towards the desired state
• These controllers include:
– Node Controller: Responsible for noticing and responding when nodes go
down.
– Replication Controller: Responsible for maintaining the correct number of
pods for every replication controller object in the system.
– Endpoints Controller: Populates the Endpoints object (that is, joins
Services & Pods).
– Service Account & Token Controllers: Create default accounts and API
access tokens for new namespaces
Dr Ganesh Neelakanta Iyer 81
cloud-controller-manager
• cloud-controller-manager runs controllers that interact
with the underlying cloud providers
• cloud-controller-manager allows cloud vendors code and
the Kubernetes code to evolve independent of each other
Dr Ganesh Neelakanta Iyer 82
kube-scheduler
• Kube-scheduler is a verbose policy-rich engine that
evaluates workload requirements and attempts to place it
on a matching resource
• These requirements can include such things as general
hardware reqs, affinity, anti-affinity, and other custom
resource requirements
Dr Ganesh Neelakanta Iyer 83
Kubernetes Node
Dr Ganesh Neelakanta Iyer 84https://www.slideshare.net/janakiramm/kubernetes-architecture
Pod
• A Pod is the basic building block of Kubernetes–the smallest and
simplest unit in the Kubernetes object model that you create or
deploy
• A Pod represents a running process on your cluster
• A Pod encapsulates an application container (or, in some cases,
multiple containers), storage resources, a unique network IP, and
options that govern how the container(s) should run
• A Pod represents a unit of deployment: a single instance of an
application in Kubernetes, which might consist of either a single
container or a small number of containers that are tightly coupled
and that share resources
Dr Ganesh Neelakanta Iyer 85
kubelet
• An agent that runs on each node in the cluster. It makes
sure that containers are running in a pod.
• The kubelet takes a set of PodSpecs that are provided
through various mechanisms and ensures that the
containers described in those PodSpecs are running and
healthy. The kubelet doesn’t manage containers which
were not created by Kubernetes
Dr Ganesh Neelakanta Iyer 86
kube-proxy
• Enables the Kubernetes service abstraction by
maintaining network rules on the host and performing
connection forwarding
Dr Ganesh Neelakanta Iyer 87
Container Runtime
• The container runtime is the software that is responsible
for running containers
• Kubernetes supports several runtimes
– Docker, rkt, runc and any OCI runtime-spec implementation
Dr Ganesh Neelakanta Iyer 88
Kubernetes Cluster
Dr Ganesh Neelakanta Iyer 89
• Kubernetes coordinates
a highly available cluster
of computers that are
connected to work as a
single unit
• Kubernetes automates
the distribution and
scheduling of application
containers across a
cluster in a more
efficient way
Running Kubernetes Locally via Minikube
• Minikube is a tool that makes it easy to run Kubernetes
locally
• Minikube runs a single-node Kubernetes cluster inside a
VM on your laptop for users looking to try out Kubernetes
or develop with it day-to-day
Dr Ganesh Neelakanta Iyer 90
Hello Minikube
Hello Minicube
• This tutorial provides a container image built from the following files
Dr Ganesh Neelakanta Iyer 92
Create a minikube cluster
• minikube version
• minikube start
• minikube dashboard
Dr Ganesh Neelakanta Iyer 93
Create a Deployment
• A Kubernetes Pod is a group of one or more Containers,
tied together for the purposes of administration and
networking
• The Pod in this tutorial has only one Container
• A Kubernetes Deployment checks on the health of your
Pod and restarts the Pod’s Container if it terminates
• Deployments are the recommended way to manage the
creation and scaling of Pods
Dr Ganesh Neelakanta Iyer 94
Create a Deployment
• Use the kubectl create command to create a
Deployment that manages a Pod
• The Pod runs a Container based on the provided Docker
image
kubectl create deployment hello-node --image=
gcr.io/hello-minikube-zero-install/hello-node
Dr Ganesh Neelakanta Iyer 95
Create a Deployment
View the deployment
kubectl get deployments
Dr Ganesh Neelakanta Iyer 96
Create a Deployment
• View the Pod
kubectl get pods
Dr Ganesh Neelakanta Iyer 97
Create a deployment
• View cluster events
kubectl get events
• View the kubectl configuration
kubectl config view
Dr Ganesh Neelakanta Iyer 98
Create s Service
• By default, the Pod is only accessible by its internal IP
address within the Kubernetes cluster
• To make the hello-node Container accessible from outside
the Kubernetes virtual network, you have to expose the
Pod as a Kubernetes Service
• Expose the Pod to the public internet using the kubectl
expose command
kubectl expose deployment hello-node --type=LoadBalancer --port=8080
Dr Ganesh Neelakanta Iyer 99
Create a Service
• View the Service you just created
kubectl get services
Dr Ganesh Neelakanta Iyer 100
Run a Service
• Run the following command
minikube service hello-node
Dr Ganesh Neelakanta Iyer 101
Bigger Experiment with Kubernetes
Deploying PHP Guestbook application with Redis
Deploying PHP Guestbook application with
Redis
• This tutorial shows you how to build and deploy a simple,
multi-tier web application using Kubernetes and Docker
• This example consists of the following components:
– A single-instance Redis master to store guestbook entries
– Multiple replicated Redis instances to serve reads
– Multiple web frontend instances
Dr Ganesh Neelakanta Iyer 104
Objectives
• Start up a Redis master
• Start up Redis slaves
• Start up the guestbook frontend
• Expose and view the Frontend Service
Dr Ganesh Neelakanta Iyer 105
Start up the Redis Master
• The guestbook application uses Redis to store its data
• It writes its data to a Redis master instance and reads
data from multiple Redis slave instances
• Creating the Redis Master Deployment
• Copy the folder here to your system
https://tinyurl.com/anokadockers
Dr Ganesh Neelakanta Iyer 106
*.yaml file
Dr Ganesh Neelakanta Iyer 107
Start up the Redis Master
• Launch a terminal window in the directory you
downloaded the manifest files
• Apply the Redis Master Deployment from the redis-
master-deployment.yaml file
kubectl apply -f redis-master-deployment.yaml
Dr Ganesh Neelakanta Iyer 108
Start up the Redis Master
• Query the list of Pods to verify that the Redis Master Pod
is running:
kubectl get pods
Dr Ganesh Neelakanta Iyer 109
Run the following command to view the logs
from the Redis Master Pod
kubectl logs -f POD-NAME
Dr Ganesh Neelakanta Iyer 110
Replace POD-NAME with the
name of your Pod
Creating the Redis Master Service
• The guestbook applications needs to communicate to the Redis
master to write its data
• You need to apply a Service to proxy the traffic to the Redis master
Pod
• A Service defines a policy to access the Pods
• Launch a terminal window in the directory you downloaded the
manifest files
• Apply the Redis Master Service from the following redis-master-
service.yaml file
kubectl apply -f redis-master-service.yaml
Dr Ganesh Neelakanta Iyer 111
Creating the Redis Master Service
• Query the list of Services to verify that the Redis Master
Service is running
• kubectl get service
Dr Ganesh Neelakanta Iyer 112
Start up the Redis Slaves
• Although the Redis master is a single pod, you can make
it highly available to meet traffic demands by adding
replica Redis slaves
Dr Ganesh Neelakanta Iyer 113
Creating the Redis Slave Deployment
• Deployments scale based off of the configurations set in
the manifest file. In this case, the Deployment object
specifies two replicas
• If there are not any replicas running, this Deployment
would start the two replicas on your container cluster
• Conversely, if there are more than two replicas are
running, it would scale down until two replicas are running
Dr Ganesh Neelakanta Iyer 114
Creating the Redis Slave Deployment
• Apply the Redis Slave Deployment from the redis-slave-
deployment.yaml file
kubectl apply -f redis-slave-deployment.yaml
Dr Ganesh Neelakanta Iyer 115
Creating the Redis Slave Deployment
• Query the list of Pods to verify that the Redis Slave Pods
are running:
kubectl get pods
Dr Ganesh Neelakanta Iyer 116
Creating the Redis Slave Service
• The guestbook application needs to communicate to
Redis slaves to read data
• To make the Redis slaves discoverable, you need to set
up a Service
• A Service provides transparent load balancing to a set of
Pods
Dr Ganesh Neelakanta Iyer 117
Creating the Redis Slave Service
• Apply the Redis Slave Service from the following redis-
slave-service.yaml file
kubectl apply -f redis-slave-service.yaml
Dr Ganesh Neelakanta Iyer 118
Creating the Redis Slave Service
• Query the list of Services to verify that the Redis slave
service is running
kubectl get services
Dr Ganesh Neelakanta Iyer 119
Set up and Expose the Guestbook Frontend
• The guestbook application has a web frontend serving the
HTTP requests written in PHP
• It is configured to connect to the redis-master Service for
write requests and the redis-slave service for Read
requests
Dr Ganesh Neelakanta Iyer 120
Creating the Guestbook Frontend
Deployment
• Apply the frontend Deployment from the frontend-
deployment.yaml file
kubectl apply -f frontend-deployment.yaml
Dr Ganesh Neelakanta Iyer 121
Creating the Guestbook Frontend
Deployment
• Query the list of Pods to verify that the three frontend
replicas are running
kubectl get pods -l app=guestbook -l
tier=frontend
Dr Ganesh Neelakanta Iyer 122
Creating the frontend service
• The redis-slave and redis-master Services you applied are
only accessible within the container cluster because the
default type for a Service is ClusterIP
• ClusterIP provides a single IP address for the set of Pods the
Service is pointing to
• This IP address is accessible only within the cluster.
• If you want guests to be able to access your guestbook, you
must configure the frontend Service to be externally visible,
so a client can request the Service from outside the container
cluster
• Minikube can only expose Services through NodePort
Dr Ganesh Neelakanta Iyer 123
Creating the frontend service
• Apply the frontend Service from the frontend-service.yaml
file
kubectl apply -f frontend-service.yaml
Dr Ganesh Neelakanta Iyer 124
Creating the frontend service
• Query the list of Services to verify that the frontend
Service is running
kubectl get services
Dr Ganesh Neelakanta Iyer 125
Viewing the Frontend Service via NodePort
• If you deployed this application to Minikube or a local
cluster, you need to find the IP address to view your
Guestbook
• Run the following command to get the IP address for the
frontend Service
minikube service frontend --url
Dr Ganesh Neelakanta Iyer 126
Go to a browser and type that URL
Dr Ganesh Neelakanta Iyer 127
Viewing the Frontend Service via
LoadBalancer
• If you deployed the frontend-service.yaml manifest with
type: LoadBalancer you need to find the IP address to
view your Guestbook
• Run the following command to get the IP address for the
frontend Service
kubectl get service frontend
Dr Ganesh Neelakanta Iyer 128
Scale the Web Frontend
• Scaling up or down is easy because your servers are
defined as a Service that uses a Deployment controller
• Run the following command to scale up the number of
frontend Pods:
kubectl scale deployment frontend --replicas=5
• Query the list of Pods to verify the number of frontend
Pods running:
kubectl get pods
Dr Ganesh Neelakanta Iyer 129
Summary
• Kubernetes can help you
– Create clusters
– Deploy applications
– Scale your business
Dr Ganesh Neelakanta Iyer 130
Dr Ganesh Neelakanta Iyer
ni_amrita@cb.amrita.edu
ganesh.vigneswara@gmail.com
GANESHNIYER

More Related Content

What's hot

Virtualization Vs. Containers
Virtualization Vs. ContainersVirtualization Vs. Containers
Virtualization Vs. Containersactualtechmedia
 
Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17Ryan Jarvinen
 
Azure kubernetes service (aks)
Azure kubernetes service (aks)Azure kubernetes service (aks)
Azure kubernetes service (aks)Akash Agrawal
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopBob Killen
 
Kubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory GuideKubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory GuideBytemark
 
Kubernetes
KubernetesKubernetes
Kuberneteserialc_w
 
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...SlideTeam
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetesDongwon Kim
 
Introduction to Docker - 2017
Introduction to Docker - 2017Introduction to Docker - 2017
Introduction to Docker - 2017Docker, Inc.
 
Containers: The What, Why, and How
Containers: The What, Why, and HowContainers: The What, Why, and How
Containers: The What, Why, and HowSneha Inguva
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes IntroductionEric Gustafson
 
OpenStack Introduction
OpenStack IntroductionOpenStack Introduction
OpenStack Introductionopenstackindia
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to DockerAditya Konarde
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesRishabh Indoria
 
Docker Basic to Advance
Docker Basic to AdvanceDocker Basic to Advance
Docker Basic to AdvanceParas Jain
 
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps WayDevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Waysmalltown
 
ArgoCD Meetup PPT final.pdf
ArgoCD Meetup PPT final.pdfArgoCD Meetup PPT final.pdf
ArgoCD Meetup PPT final.pdfamanmakwana3
 

What's hot (20)

Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
Virtualization Vs. Containers
Virtualization Vs. ContainersVirtualization Vs. Containers
Virtualization Vs. Containers
 
Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17
 
Azure kubernetes service (aks)
Azure kubernetes service (aks)Azure kubernetes service (aks)
Azure kubernetes service (aks)
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes Workshop
 
Kubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory GuideKubernetes for Beginners: An Introductory Guide
Kubernetes for Beginners: An Introductory Guide
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetes
 
Introduction to Docker - 2017
Introduction to Docker - 2017Introduction to Docker - 2017
Introduction to Docker - 2017
 
What is Docker?
What is Docker?What is Docker?
What is Docker?
 
Containers: The What, Why, and How
Containers: The What, Why, and HowContainers: The What, Why, and How
Containers: The What, Why, and How
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
OpenStack Introduction
OpenStack IntroductionOpenStack Introduction
OpenStack Introduction
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
Docker Basic to Advance
Docker Basic to AdvanceDocker Basic to Advance
Docker Basic to Advance
 
Introduction to helm
Introduction to helmIntroduction to helm
Introduction to helm
 
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps WayDevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
 
ArgoCD Meetup PPT final.pdf
ArgoCD Meetup PPT final.pdfArgoCD Meetup PPT final.pdf
ArgoCD Meetup PPT final.pdf
 

Similar to Dockers and kubernetes

Demystifying Containerization Principles for Data Scientists
Demystifying Containerization Principles for Data ScientistsDemystifying Containerization Principles for Data Scientists
Demystifying Containerization Principles for Data ScientistsDr Ganesh Iyer
 
Docker - Portable Deployment
Docker - Portable DeploymentDocker - Portable Deployment
Docker - Portable Deploymentjavaonfly
 
The challenge of application distribution - Introduction to Docker (2014 dec ...
The challenge of application distribution - Introduction to Docker (2014 dec ...The challenge of application distribution - Introduction to Docker (2014 dec ...
The challenge of application distribution - Introduction to Docker (2014 dec ...Sébastien Portebois
 
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013dotCloud
 
Week 8 lecture material
Week 8 lecture materialWeek 8 lecture material
Week 8 lecture materialAnkit Gupta
 
Are VM Passé?
Are VM Passé? Are VM Passé?
Are VM Passé? dotCloud
 
Getting Started with Docker - Nick Stinemates
Getting Started with Docker - Nick StinematesGetting Started with Docker - Nick Stinemates
Getting Started with Docker - Nick StinematesAtlassian
 
Intro Docker october 2013
Intro Docker october 2013Intro Docker october 2013
Intro Docker october 2013dotCloud
 
Intro to Docker November 2013
Intro to Docker November 2013Intro to Docker November 2013
Intro to Docker November 2013Docker, Inc.
 
Docker introduction
Docker introductionDocker introduction
Docker introductiondotCloud
 
Containerization Principles Overview for app development and deployment
Containerization Principles Overview for app development and deploymentContainerization Principles Overview for app development and deployment
Containerization Principles Overview for app development and deploymentDr Ganesh Iyer
 
State of the Container Ecosystem
State of the Container EcosystemState of the Container Ecosystem
State of the Container EcosystemVinay Rao
 
Rackspace::Solve SFO - Solve(Scale) Featuring Docker CEO Ben Golub
Rackspace::Solve SFO - Solve(Scale) Featuring Docker CEO Ben GolubRackspace::Solve SFO - Solve(Scale) Featuring Docker CEO Ben Golub
Rackspace::Solve SFO - Solve(Scale) Featuring Docker CEO Ben GolubRackspace
 
Docker and OpenStack Boston Meetup
Docker and OpenStack Boston MeetupDocker and OpenStack Boston Meetup
Docker and OpenStack Boston MeetupKamesh Pemmaraju
 

Similar to Dockers and kubernetes (20)

Demystifying Containerization Principles for Data Scientists
Demystifying Containerization Principles for Data ScientistsDemystifying Containerization Principles for Data Scientists
Demystifying Containerization Principles for Data Scientists
 
Docker - Portable Deployment
Docker - Portable DeploymentDocker - Portable Deployment
Docker - Portable Deployment
 
The challenge of application distribution - Introduction to Docker (2014 dec ...
The challenge of application distribution - Introduction to Docker (2014 dec ...The challenge of application distribution - Introduction to Docker (2014 dec ...
The challenge of application distribution - Introduction to Docker (2014 dec ...
 
Webinar Docker Tri Series
Webinar Docker Tri SeriesWebinar Docker Tri Series
Webinar Docker Tri Series
 
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
 
OpenStack Summit
OpenStack SummitOpenStack Summit
OpenStack Summit
 
Week 8 lecture material
Week 8 lecture materialWeek 8 lecture material
Week 8 lecture material
 
Are VM Passé?
Are VM Passé? Are VM Passé?
Are VM Passé?
 
Are VMs Passé?
Are VMs Passé?Are VMs Passé?
Are VMs Passé?
 
Docker-Intro
Docker-IntroDocker-Intro
Docker-Intro
 
Getting Started with Docker - Nick Stinemates
Getting Started with Docker - Nick StinematesGetting Started with Docker - Nick Stinemates
Getting Started with Docker - Nick Stinemates
 
Intro Docker october 2013
Intro Docker october 2013Intro Docker october 2013
Intro Docker october 2013
 
Intro to Docker November 2013
Intro to Docker November 2013Intro to Docker November 2013
Intro to Docker November 2013
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Containerization Principles Overview for app development and deployment
Containerization Principles Overview for app development and deploymentContainerization Principles Overview for app development and deployment
Containerization Principles Overview for app development and deployment
 
State of the Container Ecosystem
State of the Container EcosystemState of the Container Ecosystem
State of the Container Ecosystem
 
Rackspace::Solve SFO - Solve(Scale) Featuring Docker CEO Ben Golub
Rackspace::Solve SFO - Solve(Scale) Featuring Docker CEO Ben GolubRackspace::Solve SFO - Solve(Scale) Featuring Docker CEO Ben Golub
Rackspace::Solve SFO - Solve(Scale) Featuring Docker CEO Ben Golub
 
Docker and OpenStack Boston Meetup
Docker and OpenStack Boston MeetupDocker and OpenStack Boston Meetup
Docker and OpenStack Boston Meetup
 
Docker
DockerDocker
Docker
 
Docker intro
Docker introDocker intro
Docker intro
 

More from Dr Ganesh Iyer

SRE Demystified - 16 - NALSD - Non-Abstract Large System Design
SRE Demystified - 16 - NALSD - Non-Abstract Large System DesignSRE Demystified - 16 - NALSD - Non-Abstract Large System Design
SRE Demystified - 16 - NALSD - Non-Abstract Large System DesignDr Ganesh Iyer
 
SRE Demystified - 14 - SRE Practices overview
SRE Demystified - 14 - SRE Practices overviewSRE Demystified - 14 - SRE Practices overview
SRE Demystified - 14 - SRE Practices overviewDr Ganesh Iyer
 
SRE Demystified - 13 - Docs that matter -2
SRE Demystified - 13 - Docs that matter -2SRE Demystified - 13 - Docs that matter -2
SRE Demystified - 13 - Docs that matter -2Dr Ganesh Iyer
 
SRE Demystified - 12 - Docs that matter -1
SRE Demystified - 12 - Docs that matter -1 SRE Demystified - 12 - Docs that matter -1
SRE Demystified - 12 - Docs that matter -1 Dr Ganesh Iyer
 
SRE Demystified - 01 - SLO SLI and SLA
SRE Demystified - 01 - SLO SLI and SLASRE Demystified - 01 - SLO SLI and SLA
SRE Demystified - 01 - SLO SLI and SLADr Ganesh Iyer
 
SRE Demystified - 11 - Release management-2
SRE Demystified - 11 - Release management-2SRE Demystified - 11 - Release management-2
SRE Demystified - 11 - Release management-2Dr Ganesh Iyer
 
SRE Demystified - 10 - Release management-1
SRE Demystified - 10 - Release management-1SRE Demystified - 10 - Release management-1
SRE Demystified - 10 - Release management-1Dr Ganesh Iyer
 
SRE Demystified - 09 - Simplicity
SRE Demystified - 09 - SimplicitySRE Demystified - 09 - Simplicity
SRE Demystified - 09 - SimplicityDr Ganesh Iyer
 
SRE Demystified - 07 - Practical Alerting
SRE Demystified - 07 - Practical AlertingSRE Demystified - 07 - Practical Alerting
SRE Demystified - 07 - Practical AlertingDr Ganesh Iyer
 
SRE Demystified - 06 - Distributed Monitoring
SRE Demystified - 06 - Distributed MonitoringSRE Demystified - 06 - Distributed Monitoring
SRE Demystified - 06 - Distributed MonitoringDr Ganesh Iyer
 
SRE Demystified - 05 - Toil Elimination
SRE Demystified - 05 - Toil EliminationSRE Demystified - 05 - Toil Elimination
SRE Demystified - 05 - Toil EliminationDr Ganesh Iyer
 
SRE Demystified - 04 - Engagement Model
SRE Demystified - 04 - Engagement ModelSRE Demystified - 04 - Engagement Model
SRE Demystified - 04 - Engagement ModelDr Ganesh Iyer
 
SRE Demystified - 03 - Choosing SLIs and SLOs
SRE Demystified - 03 - Choosing SLIs and SLOsSRE Demystified - 03 - Choosing SLIs and SLOs
SRE Demystified - 03 - Choosing SLIs and SLOsDr Ganesh Iyer
 
Machine Learning for Statisticians - Introduction
Machine Learning for Statisticians - IntroductionMachine Learning for Statisticians - Introduction
Machine Learning for Statisticians - IntroductionDr Ganesh Iyer
 
Making Decisions - A Game Theoretic approach
Making Decisions - A Game Theoretic approachMaking Decisions - A Game Theoretic approach
Making Decisions - A Game Theoretic approachDr Ganesh Iyer
 
Game Theory and Engineering Applications
Game Theory and Engineering ApplicationsGame Theory and Engineering Applications
Game Theory and Engineering ApplicationsDr Ganesh Iyer
 
Machine Learning and its Applications
Machine Learning and its ApplicationsMachine Learning and its Applications
Machine Learning and its ApplicationsDr Ganesh Iyer
 
How to become a successful entrepreneur
How to become a successful entrepreneurHow to become a successful entrepreneur
How to become a successful entrepreneurDr Ganesh Iyer
 
Game Theory and Engineering Applications
Game Theory and Engineering ApplicationsGame Theory and Engineering Applications
Game Theory and Engineering ApplicationsDr Ganesh Iyer
 

More from Dr Ganesh Iyer (20)

SRE Demystified - 16 - NALSD - Non-Abstract Large System Design
SRE Demystified - 16 - NALSD - Non-Abstract Large System DesignSRE Demystified - 16 - NALSD - Non-Abstract Large System Design
SRE Demystified - 16 - NALSD - Non-Abstract Large System Design
 
SRE Demystified - 14 - SRE Practices overview
SRE Demystified - 14 - SRE Practices overviewSRE Demystified - 14 - SRE Practices overview
SRE Demystified - 14 - SRE Practices overview
 
SRE Demystified - 13 - Docs that matter -2
SRE Demystified - 13 - Docs that matter -2SRE Demystified - 13 - Docs that matter -2
SRE Demystified - 13 - Docs that matter -2
 
SRE Demystified - 12 - Docs that matter -1
SRE Demystified - 12 - Docs that matter -1 SRE Demystified - 12 - Docs that matter -1
SRE Demystified - 12 - Docs that matter -1
 
SRE Demystified - 01 - SLO SLI and SLA
SRE Demystified - 01 - SLO SLI and SLASRE Demystified - 01 - SLO SLI and SLA
SRE Demystified - 01 - SLO SLI and SLA
 
SRE Demystified - 11 - Release management-2
SRE Demystified - 11 - Release management-2SRE Demystified - 11 - Release management-2
SRE Demystified - 11 - Release management-2
 
SRE Demystified - 10 - Release management-1
SRE Demystified - 10 - Release management-1SRE Demystified - 10 - Release management-1
SRE Demystified - 10 - Release management-1
 
SRE Demystified - 09 - Simplicity
SRE Demystified - 09 - SimplicitySRE Demystified - 09 - Simplicity
SRE Demystified - 09 - Simplicity
 
SRE Demystified - 07 - Practical Alerting
SRE Demystified - 07 - Practical AlertingSRE Demystified - 07 - Practical Alerting
SRE Demystified - 07 - Practical Alerting
 
SRE Demystified - 06 - Distributed Monitoring
SRE Demystified - 06 - Distributed MonitoringSRE Demystified - 06 - Distributed Monitoring
SRE Demystified - 06 - Distributed Monitoring
 
SRE Demystified - 05 - Toil Elimination
SRE Demystified - 05 - Toil EliminationSRE Demystified - 05 - Toil Elimination
SRE Demystified - 05 - Toil Elimination
 
SRE Demystified - 04 - Engagement Model
SRE Demystified - 04 - Engagement ModelSRE Demystified - 04 - Engagement Model
SRE Demystified - 04 - Engagement Model
 
SRE Demystified - 03 - Choosing SLIs and SLOs
SRE Demystified - 03 - Choosing SLIs and SLOsSRE Demystified - 03 - Choosing SLIs and SLOs
SRE Demystified - 03 - Choosing SLIs and SLOs
 
Machine Learning for Statisticians - Introduction
Machine Learning for Statisticians - IntroductionMachine Learning for Statisticians - Introduction
Machine Learning for Statisticians - Introduction
 
Making Decisions - A Game Theoretic approach
Making Decisions - A Game Theoretic approachMaking Decisions - A Game Theoretic approach
Making Decisions - A Game Theoretic approach
 
Cloud and Industry4.0
Cloud and Industry4.0Cloud and Industry4.0
Cloud and Industry4.0
 
Game Theory and Engineering Applications
Game Theory and Engineering ApplicationsGame Theory and Engineering Applications
Game Theory and Engineering Applications
 
Machine Learning and its Applications
Machine Learning and its ApplicationsMachine Learning and its Applications
Machine Learning and its Applications
 
How to become a successful entrepreneur
How to become a successful entrepreneurHow to become a successful entrepreneur
How to become a successful entrepreneur
 
Game Theory and Engineering Applications
Game Theory and Engineering ApplicationsGame Theory and Engineering Applications
Game Theory and Engineering Applications
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringWSO2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewDianaGray10
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governanceWSO2
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaWSO2
 

Recently uploaded (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 

Dockers and kubernetes

  • 1. Dockers and Kubernetes A way to build scalable and portable applications with Cloud Dr Ganesh Neelakanta Iyer Amrita Vishwa Vidyapeetham, Coimbatore Associate Professor, Dept of Computer Science and Engg
  • 2. About Me • Associate Professor, Amrita Vishwa Vidyapeetham • Masters & PhD from National University of Singapore (NUS) • Several years in Industry/Academia • Sasken Communications, NXP Semiconductors, Progress Software, IIIT-HYD, NUS (Singapore) • Architect, Manager, Technology Evangelist, Visiting Faculty • Talks/workshops in USA, Europe, Australia, Asia • Cloud/Edge Computing, IoT, Game Theory, Software QA • Kathakali Artist, Composer, Speaker, Traveler, Photographer GANESHNIYER http://ganeshniyer.com
  • 3. Outline • Dockers • Need for Orchestration • Kubernetes
  • 4. How many worked on Kubernetes? Dr Ganesh Neelakanta Iyer 4
  • 5. How many of you have worked on Dockers? Dr Ganesh Neelakanta Iyer 5
  • 6. How many of you have heard of dockers?
  • 7. How many know what is Cloud Computing?
  • 9. Flashback – Lets go back to pre-1960’s
  • 10.
  • 12. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Also an M x N Matrix
  • 13. Multiplicityof Goods Multiplicityof methodsfor transporting/storing DoIworryabout howgoodsinteract (e.g.coffeebeans nexttospices) CanItransport quicklyand smoothly (e.g.fromboatto traintotruck) Solution: Intermodal Shipping Container …in between, can be loaded and unloaded, stacked, transported efficiently over long distances, and transferred from one mode of transport to another A standard container that is loaded with virtually any goods, and stays sealed until it reaches final delivery.
  • 14. This eliminated the M x N problem…
  • 15. and spawned an Intermodal Shipping Container Ecosystem • 90% of all cargo now shipped in a standard container • Order of magnitude reduction in cost and time to load and unload ships • Massive reduction in losses due to theft or damage • Huge reduction in freight cost as percent of final goods (from >25% to <3%) massive globalizations • 5000 ships deliver 200M containers per year
  • 16. Static website Web frontend User DB Queue Analytics DB Background workers API endpoint nginx 1.5 + modsecurity + openssl + bootstrap 2 postgresql + pgv8 + v8 hadoop + hive + thrift + OpenJDK Ruby + Rails + sass + Unicorn Redis + redis-sentinel Python 3.0 + celery + pyredis + libcurl + ffmpeg + libopencv + nodejs + phantomjs Python 2.7 + Flask + pyredis + celery + psycopg + postgresql-client Development VM QA server Public Cloud Disaster recovery Contributor’s laptop Production Servers The Challenge Multiplicityof Stacks Multiplicityof hardware environments Production Cluster Customer Data Center Doservicesand appsinteract appropriately? CanImigrate smoothlyand quickly?
  • 17. Results in M x N compatibility nightmare Static website Web frontend Background workers User DB Analytics DB Queue Development VM QA Server Single Prod Server Onsite Cluster Public Cloud Contributor’s laptop Customer Servers ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
  • 18. Static website Web frontendUser DB Queue Analytics DB Development VM QA server Public Cloud Contributor’s laptop Docker is a shipping container system for code Multiplicityof Stacks Multiplicityof hardware environments Production Cluster Customer Data Center Doservicesand appsinteract appropriately? CanImigrate smoothlyand quickly …that can be manipulated using standard operations and run consistently on virtually any hardware platform An engine that enables any payload to be encapsulated as a lightweight, portable, self-sufficient container…
  • 19. Static website Web frontendUser DB Queue Analytics DB Development VM QA server Public Cloud Contributor’s laptop Or…put more simply Multiplicityof Stacks Multiplicityof hardware environments Production Cluster Customer Data Center Doservicesand appsinteract appropriately? CanImigrate smoothlyand quickly Operator: Configure Once, Run Anything Developer: Build Once, Run Anywhere (Finally)
  • 20. Static website Web frontend Background workers User DB Analytics DB Queue Development VM QA Server Single Prod Server Onsite Cluster Public Cloud Contributor’s laptop Customer Servers Docker solves the M x N problem
  • 21. Docker containers • Wrap up a piece of software in a complete file system that contains everything it needs to run: – Code, runtime, system tools, system libraries – Anything you can install on a server • This guarantees that it will always run the same, regardless of the environment it is running in
  • 22. Why containers matter Physical Containers Docker Content Agnostic The same container can hold almost any type of cargo Can encapsulate any payload and its dependencies Hardware Agnostic Standard shape and interface allow same container to move from ship to train to semi-truck to warehouse to crane without being modified or opened Using operating system primitives (e.g. LXC) can run consistently on virtually any hardware—VMs, bare metal, openstack, public IAAS, etc.—without modification Content Isolation and Interaction No worry about anvils crushing bananas. Containers can be stacked and shipped together Resource, network, and content isolation. Avoids dependency hell Automation Standard interfaces make it easy to automate loading, unloading, moving, etc. Standard operations to run, start, stop, commit, search, etc. Perfect for devops: CI, CD, autoscaling, hybrid clouds Highly efficient No opening or modification, quick to move between waypoints Lightweight, virtually no perf or start-up penalty, quick to move and manipulate Separation of duties Shipper worries about inside of box, carrier worries about outside of box Developer worries about code. Ops worries about infrastructure.
  • 23. Docker containers Lightweight • Containers running on one machine all share the same OS kernel • They start instantly and make more efficient use of RAM • Images are constructed from layered file systems • They can share common files, making disk usage and image downloads much more efficient Open • Based on open standards • Allowing containers to run on all major Linux distributions and Microsoft OS with support for every infrastructure Secure • Containers isolate applications from each other and the underlying infrastructure while providing an added layer of protection for the application
  • 24. Docker / Containers vs. Virtual Machine https://www.docker.com/whatisdocker/ Containers have similar resource isolation and allocation benefits as VMs but a different architectural approach allows them to be much more portable and efficient
  • 25. Virtual Machines Virtual machines run guest operating systems—note the OS layer in each box. This is resource intensive, and the resulting disk image and application state is an entanglement of OS settings, system-installed dependencies, OS security patches, and other easy-to-lose, hard-to-replicate ephemera Containers vs Virtual Machines Containers Containers can share a single kernel, and the only information that needs to be in a container image is the executable and its package dependencies, which never need to be installed on the host system. These processes run like native processes, and you can manage them individually
  • 26. Why are Docker containers lightweight? Bins/ Libs App A Original App (No OS to take up space, resources, or require restart) AppΔ Bins / App A Bins/ Libs App A’ Gues t OS Bins/ Libs Modified App Union file system allows us to only save the diffs Between container A and container A’ VMs Every app, every copy of an app, and every slight modification of the app requires a new virtual server App A Guest OS Bins/ Libs Copy of App No OS. Can Share bins/libs App A Guest OS Guest OS VMs Containers
  • 27. What are the basics of the Docker system? Source Code Repository Dockerfile For A Docker Engine Docker Container Image Registry Build Docker Engine Host 2 OS 2 (Windows / Linux) Container A Container B Container C ContainerA Push Search Pull Run Host 1 OS (Linux)
  • 28. Changes and Updates Docker Engine Docker Container Image Registry Docker Engine Push Update Bins/ Libs App A AppΔ Bins / Base Container Image Host is now running A’’ Container Mod A’’ AppΔ Bins / Bins/ Libs App A Bins / Bins/ Libs App A’’ Host running A wants to upgrade to A’’. Requests update. Gets only diffs Container Mod A’
  • 29. Easily Share and Collaborate on Applications • Distribute and share content – Store, distribute and manage your Docker images in your Docker Hub with your team – Image updates, changes and history are automatically shared across your organization. • Simply share your application with others – Ship your containers to others without worrying about different environment dependencies creating issues with your application. – Other teams can easily link to or test against your app without having to learn or worry about how it works. Docker creates a common framework for developers and sysadmins to work together on distributed applications
  • 30. Get Started with Docker • Install Docker • Run a software image in a container • Browse for an image on Docker Hub • Create your own image and run it in a container • Create a Docker Hub account and an image repository • Create an image of your own • Push your image to Docker Hub for others to use https://www.docker.com/products/docker https://www.docker.com/products/docker-toolbox
  • 31. Docker Container as a Service (CaaS) Deliver an IT secured and managed application environment for developers to build and deploy applications in a self service manner
  • 34. Continuous Integration and Deployment (CI / CD)
  • 37. How does this help you build better software? • Stop wasting hours trying to setup developer environments • Spin up new instances and make copies of production code to run locally • With Docker, you can easily take copies of your live environment and run on any new endpoint running Docker. Accelerate Developer Onboarding • The isolation capabilities of Docker containers free developers from the worries of using “approved” language stacks and tooling • Developers can use the best language and tools for their application service without worrying about causing conflict issues Empower Developer Creativity • By packaging up the application with its configs and dependencies together and shipping as a container, the application will always work as designed locally, on another machine, in test or production • No more worries about having to install the same configs into a different environment Eliminate Environment Inconsistencies
  • 38.
  • 40. Setting up • Before we get started, make sure your system has the latest version of Docker installed. • Docker is available in two editions: Community Edition (CE) and Enterprise Edition (EE). • Docker Community Edition (CE) is ideal for developers and small teams looking to get started with Docker and experimenting with container-based apps. Docker CE has two update channels, stable and edge: – Stable gives you reliable updates every quarter – Edge gives you new features every month • Docker Enterprise Edition (EE) is designed for enterprise development and IT teams who build, ship, and run business critical applications in production at scale.
  • 42. In this session, I use Docker for Windows Desktop
  • 44. If your windows is not in latest version… https://docs.docker.com/docker-for-windows/release-notes/#docker-community-edition-17062-ce-win27-2017-09-06-stable
  • 45. Docker for Windows When the whale in the status bar stays steady, Docker is up-and-running, and accessible from any terminal window.
  • 46. Hello-world • Open command prompt / windows power shell and run docker run hello-world ▪ Now would also be a good time to make sure you are using version 1.13 or higher. Run docker --version to check it out.
  • 47. Building an app the Docker way • In the past, if you were to start writing a Python app, your first order of business was to install a Python runtime onto your machine • But, that creates a situation where the environment on your machine has to be just so in order for your app to run as expected; ditto for the server that runs your app • With Docker, you can just grab a portable Python runtime as an image, no installation necessary • Then, your build can include the base Python image right alongside your app code, ensuring that your app, its dependencies, and the runtime, all travel together • These portable images are defined by something called a Dockerfile
  • 48. Define a container with a Dockerfile • Dockerfile will define what goes on in the environment inside your container • Access to resources like networking interfaces and disk drives is virtualized inside this environment, which is isolated from the rest of your system, so you have to map ports to the outside world, and be specific about what files you want to “copy in” to that environment • However, after doing that, you can expect that the build of your app defined in this Dockerfile will behave exactly the same wherever it runs
  • 49. Dockerfile • Create an empty directory • Change directories (cd) into the new directory, create a file called Dockerfile
  • 50. Dockerfile • In windows, open notepad, copy the content below, click on Save as, type “Dockerfile” This Dockerfile refers to a couple of files we haven’t created yet, namely app.py and requirements.txt. Let’s create those next.
  • 51. The app itself • Create two more files, requirements.txt and app.py, and put them in the same folder with the Dockerfile • This completes our app, which as you can see is quite simple • When the above Dockerfile is built into an image, app.py and requirements.txt will be present because of that Dockerfile’s ADD command, and the output from app.py will be accessible over HTTP thanks to the EXPOSE command.
  • 52. The App itself Requirements.txt app.py That’s it! You don’t need Python or anything in requirements.txt on your system, nor will building or running this image install them on your system. It doesn’t seem like you’ve really set up an environment with Python and Flask, but you have.
  • 53. Building the app • We are ready to build the app. Make sure you are still at the top level of your new directory. Here’s what ls should show • Now run the build command. This creates a Docker image, which we’re going to tag using -t so it has a friendly name.
  • 54. Building the app • docker build -t friendlyhello .
  • 55. Where is your built images? • docker images
  • 56. Run the app • Run the app, mapping your machine’s port 4000 to the container’s published port 80 using –p • docker run -p 4000:80 friendlyhello • You should see a notice that Python is serving your app at http://0.0.0.0:80. But that message is coming from inside the container, which doesn’t know you mapped port 80 of that container to 4000, making the correct URL http://localhost:4000 • Go to that URL in a web browser to see the display content served up on a web page, including “Hello World” text, the container ID, and the Redis error message
  • 57.
  • 58. End the process • Hit CTRL+C in your terminal to quit • Now use docker stop to end the process, using the CONTAINER ID, like so
  • 59. • Now let’s run the app in the background, in detached mode: • docker run -d -p 4000:80 friendlyhello • You get the long container ID for your app and then are kicked back to your terminal. Your container is running in the background. You can also see the abbreviated container ID with docker container ls (and both work interchangeably when running commands): • docker container ls
  • 60. Share image • To demonstrate the portability of what we just created, let’s upload our built image and run it somewhere else • After all, you’ll need to learn how to push to registries when you want to deploy containers to production • A registry is a collection of repositories, and a repository is a collection of images—sort of like a GitHub repository, except the code is already built. An account on a registry can create many repositories. The docker CLI uses Docker’s public registry by default • If you don’t have a Docker account, sign up for one at cloud.docker.com. Make note of your username.
  • 61.
  • 62.
  • 63. Login with your docker id • Log in to the Docker public registry on your local machine. • docker login
  • 64. Tag the image • The notation for associating a local image with a repository on a registry is username/repository:tag. The tag is optional, but recommended, since it is the mechanism that registries use to give Docker images a version. Give the repository and tag meaningful names for the context, such as get-started:part1. This will put the image in the get-started repository and tag it as part1. • Now, put it all together to tag the image. Run docker tag image with your username, repository, and tag names so that the image will upload to your desired destination. The syntax of the command is:
  • 66. Publish the image • Upload your tagged image to the repository • docker push username/repository:tag • Once complete, the results of this upload are publicly available. If you log in to Docker Hub, you will see the new image there, with its pull command
  • 67. Publish the image • Upload your tagged image to the repository • docker push username/repository:tag • Once complete, the results of this upload are publicly available. If you log in to Docker Hub, you will see the new image there, with its pull command
  • 68.
  • 69. Pull and run the image from the remote repository • From now on, you can use docker run and run your app on any machine with this command: • docker run -p 4000:80 username/repository:tag • If the image isn’t available locally on the machine, Docker will pull it from the repository. • If you don’t specify the :tag portion of these commands, the tag of :latest will be assumed, both when you build and when you run images. Docker will use the last version of the image that ran without a tag specified (not necessarily the most recent image). No matter where executes, it pulls your image, along with Python and all the dependencies from , and runs your code. It all travels together in a neat little package, and the host machine doesn’t have to install anything but Docker to run it.
  • 70. What have you seen so far? • Basics of Docker • How to create your first app in the Docker way • Building the app • Run the app • Sharing and Publishing images • Pull and run images
  • 72. The Need for Orchestration Systems • While Docker provided an open standard for packaging and distributing containerized applications, there arose a new problem – How would all of these containers be coordinated and scheduled? – How do all the different containers in your application communicate with each other? – How can container instances be scaled? Dr Ganesh Neelakanta Iyer 72
  • 73. Solution Container Orchestration Systems Dr Ganesh Neelakanta Iyer 73
  • 74. From Containers to Kubernetes VM Host OS Container Runtime Benefits Isolation Immutable infrastructure Portability Faster deployments Versioning Ease of sharing Challenges Networking Deployments Service Discovery Auto Scaling Persisting Data Logging, Monitoring Access Control Kubernetes Orchestration of cluster of containers across multiple hosts • Automatic placements, networking, deployments, scaling, roll-out/-back, A/B testing Docker Workload Portability • Abstract from cloud provider specifics • Multiple container runtimes Declarative – not procedural • Declare target state, reconcile to desired state • Self-healing Container Scheduler Container
  • 75. Kubernetes • Kubernetes is an open-source container cluster manager – originally developed by Google, donated to the Cloud Native Computing Foundation – schedules & deploys containers onto a cluster of machines • e.g. ensure that a specified number of instances of an application are running – provides service discovery, distribution of configuration & secrets, ... – provides access to persistent storage • Pod – smallest deployable unit of compute – consists of one or more containers that are always co-located, co- scheduled & run in a shared context 5
  • 76. Why Kubernetes? • It can be run anywhere – on-premises • bare metal, OpenStack, ... – public clouds • Google, Azure, AWS, ... • Aim is to use Kubernetes as an abstraction layer – migrate to containerised applications managed by Kubernetes & use only the Kubernetes API – can then run out-of-the-box on any Kubernetes cluster • Avoid vendor lock-in as much as possible by not using any vendor specific APIs or services – except where Kubernetes provides an abstraction • e.g. storage, load balancers 7
  • 77. Kubernetes Architecture Dr Ganesh Neelakanta Iyer 77https://www.slideshare.net/janakiramm/kubernetes-architecture
  • 78. Kubernetes Master Dr Ganesh Neelakanta Iyer 78https://www.slideshare.net/janakiramm/kubernetes-architecture
  • 79. kube-apiserver • The apiserver provides a forward facing REST interface into the kubernetes control plane and datastore • All clients, including nodes, users and other applications interact with kubernetes strictly through the API Server • It is the true core of Kubernetes acting as the gatekeeper to the cluster by handling authentication and authorization, request validation, mutation, and admission control in addition to being the front-end to the backing datastore Dr Ganesh Neelakanta Iyer 79
  • 80. etcd • Etcd acts as the cluster datastore • Providing a strong, consistent and highly available key- value store used for persisting cluster state Dr Ganesh Neelakanta Iyer 80
  • 81. kube-controller-manager • The controller-manager is the primary daemon that manages all core component control loops • It monitors the cluster state via the apiserver and steers the cluster towards the desired state • These controllers include: – Node Controller: Responsible for noticing and responding when nodes go down. – Replication Controller: Responsible for maintaining the correct number of pods for every replication controller object in the system. – Endpoints Controller: Populates the Endpoints object (that is, joins Services & Pods). – Service Account & Token Controllers: Create default accounts and API access tokens for new namespaces Dr Ganesh Neelakanta Iyer 81
  • 82. cloud-controller-manager • cloud-controller-manager runs controllers that interact with the underlying cloud providers • cloud-controller-manager allows cloud vendors code and the Kubernetes code to evolve independent of each other Dr Ganesh Neelakanta Iyer 82
  • 83. kube-scheduler • Kube-scheduler is a verbose policy-rich engine that evaluates workload requirements and attempts to place it on a matching resource • These requirements can include such things as general hardware reqs, affinity, anti-affinity, and other custom resource requirements Dr Ganesh Neelakanta Iyer 83
  • 84. Kubernetes Node Dr Ganesh Neelakanta Iyer 84https://www.slideshare.net/janakiramm/kubernetes-architecture
  • 85. Pod • A Pod is the basic building block of Kubernetes–the smallest and simplest unit in the Kubernetes object model that you create or deploy • A Pod represents a running process on your cluster • A Pod encapsulates an application container (or, in some cases, multiple containers), storage resources, a unique network IP, and options that govern how the container(s) should run • A Pod represents a unit of deployment: a single instance of an application in Kubernetes, which might consist of either a single container or a small number of containers that are tightly coupled and that share resources Dr Ganesh Neelakanta Iyer 85
  • 86. kubelet • An agent that runs on each node in the cluster. It makes sure that containers are running in a pod. • The kubelet takes a set of PodSpecs that are provided through various mechanisms and ensures that the containers described in those PodSpecs are running and healthy. The kubelet doesn’t manage containers which were not created by Kubernetes Dr Ganesh Neelakanta Iyer 86
  • 87. kube-proxy • Enables the Kubernetes service abstraction by maintaining network rules on the host and performing connection forwarding Dr Ganesh Neelakanta Iyer 87
  • 88. Container Runtime • The container runtime is the software that is responsible for running containers • Kubernetes supports several runtimes – Docker, rkt, runc and any OCI runtime-spec implementation Dr Ganesh Neelakanta Iyer 88
  • 89. Kubernetes Cluster Dr Ganesh Neelakanta Iyer 89 • Kubernetes coordinates a highly available cluster of computers that are connected to work as a single unit • Kubernetes automates the distribution and scheduling of application containers across a cluster in a more efficient way
  • 90. Running Kubernetes Locally via Minikube • Minikube is a tool that makes it easy to run Kubernetes locally • Minikube runs a single-node Kubernetes cluster inside a VM on your laptop for users looking to try out Kubernetes or develop with it day-to-day Dr Ganesh Neelakanta Iyer 90
  • 92. Hello Minicube • This tutorial provides a container image built from the following files Dr Ganesh Neelakanta Iyer 92
  • 93. Create a minikube cluster • minikube version • minikube start • minikube dashboard Dr Ganesh Neelakanta Iyer 93
  • 94. Create a Deployment • A Kubernetes Pod is a group of one or more Containers, tied together for the purposes of administration and networking • The Pod in this tutorial has only one Container • A Kubernetes Deployment checks on the health of your Pod and restarts the Pod’s Container if it terminates • Deployments are the recommended way to manage the creation and scaling of Pods Dr Ganesh Neelakanta Iyer 94
  • 95. Create a Deployment • Use the kubectl create command to create a Deployment that manages a Pod • The Pod runs a Container based on the provided Docker image kubectl create deployment hello-node --image= gcr.io/hello-minikube-zero-install/hello-node Dr Ganesh Neelakanta Iyer 95
  • 96. Create a Deployment View the deployment kubectl get deployments Dr Ganesh Neelakanta Iyer 96
  • 97. Create a Deployment • View the Pod kubectl get pods Dr Ganesh Neelakanta Iyer 97
  • 98. Create a deployment • View cluster events kubectl get events • View the kubectl configuration kubectl config view Dr Ganesh Neelakanta Iyer 98
  • 99. Create s Service • By default, the Pod is only accessible by its internal IP address within the Kubernetes cluster • To make the hello-node Container accessible from outside the Kubernetes virtual network, you have to expose the Pod as a Kubernetes Service • Expose the Pod to the public internet using the kubectl expose command kubectl expose deployment hello-node --type=LoadBalancer --port=8080 Dr Ganesh Neelakanta Iyer 99
  • 100. Create a Service • View the Service you just created kubectl get services Dr Ganesh Neelakanta Iyer 100
  • 101. Run a Service • Run the following command minikube service hello-node Dr Ganesh Neelakanta Iyer 101
  • 102. Bigger Experiment with Kubernetes
  • 103. Deploying PHP Guestbook application with Redis
  • 104. Deploying PHP Guestbook application with Redis • This tutorial shows you how to build and deploy a simple, multi-tier web application using Kubernetes and Docker • This example consists of the following components: – A single-instance Redis master to store guestbook entries – Multiple replicated Redis instances to serve reads – Multiple web frontend instances Dr Ganesh Neelakanta Iyer 104
  • 105. Objectives • Start up a Redis master • Start up Redis slaves • Start up the guestbook frontend • Expose and view the Frontend Service Dr Ganesh Neelakanta Iyer 105
  • 106. Start up the Redis Master • The guestbook application uses Redis to store its data • It writes its data to a Redis master instance and reads data from multiple Redis slave instances • Creating the Redis Master Deployment • Copy the folder here to your system https://tinyurl.com/anokadockers Dr Ganesh Neelakanta Iyer 106
  • 107. *.yaml file Dr Ganesh Neelakanta Iyer 107
  • 108. Start up the Redis Master • Launch a terminal window in the directory you downloaded the manifest files • Apply the Redis Master Deployment from the redis- master-deployment.yaml file kubectl apply -f redis-master-deployment.yaml Dr Ganesh Neelakanta Iyer 108
  • 109. Start up the Redis Master • Query the list of Pods to verify that the Redis Master Pod is running: kubectl get pods Dr Ganesh Neelakanta Iyer 109
  • 110. Run the following command to view the logs from the Redis Master Pod kubectl logs -f POD-NAME Dr Ganesh Neelakanta Iyer 110 Replace POD-NAME with the name of your Pod
  • 111. Creating the Redis Master Service • The guestbook applications needs to communicate to the Redis master to write its data • You need to apply a Service to proxy the traffic to the Redis master Pod • A Service defines a policy to access the Pods • Launch a terminal window in the directory you downloaded the manifest files • Apply the Redis Master Service from the following redis-master- service.yaml file kubectl apply -f redis-master-service.yaml Dr Ganesh Neelakanta Iyer 111
  • 112. Creating the Redis Master Service • Query the list of Services to verify that the Redis Master Service is running • kubectl get service Dr Ganesh Neelakanta Iyer 112
  • 113. Start up the Redis Slaves • Although the Redis master is a single pod, you can make it highly available to meet traffic demands by adding replica Redis slaves Dr Ganesh Neelakanta Iyer 113
  • 114. Creating the Redis Slave Deployment • Deployments scale based off of the configurations set in the manifest file. In this case, the Deployment object specifies two replicas • If there are not any replicas running, this Deployment would start the two replicas on your container cluster • Conversely, if there are more than two replicas are running, it would scale down until two replicas are running Dr Ganesh Neelakanta Iyer 114
  • 115. Creating the Redis Slave Deployment • Apply the Redis Slave Deployment from the redis-slave- deployment.yaml file kubectl apply -f redis-slave-deployment.yaml Dr Ganesh Neelakanta Iyer 115
  • 116. Creating the Redis Slave Deployment • Query the list of Pods to verify that the Redis Slave Pods are running: kubectl get pods Dr Ganesh Neelakanta Iyer 116
  • 117. Creating the Redis Slave Service • The guestbook application needs to communicate to Redis slaves to read data • To make the Redis slaves discoverable, you need to set up a Service • A Service provides transparent load balancing to a set of Pods Dr Ganesh Neelakanta Iyer 117
  • 118. Creating the Redis Slave Service • Apply the Redis Slave Service from the following redis- slave-service.yaml file kubectl apply -f redis-slave-service.yaml Dr Ganesh Neelakanta Iyer 118
  • 119. Creating the Redis Slave Service • Query the list of Services to verify that the Redis slave service is running kubectl get services Dr Ganesh Neelakanta Iyer 119
  • 120. Set up and Expose the Guestbook Frontend • The guestbook application has a web frontend serving the HTTP requests written in PHP • It is configured to connect to the redis-master Service for write requests and the redis-slave service for Read requests Dr Ganesh Neelakanta Iyer 120
  • 121. Creating the Guestbook Frontend Deployment • Apply the frontend Deployment from the frontend- deployment.yaml file kubectl apply -f frontend-deployment.yaml Dr Ganesh Neelakanta Iyer 121
  • 122. Creating the Guestbook Frontend Deployment • Query the list of Pods to verify that the three frontend replicas are running kubectl get pods -l app=guestbook -l tier=frontend Dr Ganesh Neelakanta Iyer 122
  • 123. Creating the frontend service • The redis-slave and redis-master Services you applied are only accessible within the container cluster because the default type for a Service is ClusterIP • ClusterIP provides a single IP address for the set of Pods the Service is pointing to • This IP address is accessible only within the cluster. • If you want guests to be able to access your guestbook, you must configure the frontend Service to be externally visible, so a client can request the Service from outside the container cluster • Minikube can only expose Services through NodePort Dr Ganesh Neelakanta Iyer 123
  • 124. Creating the frontend service • Apply the frontend Service from the frontend-service.yaml file kubectl apply -f frontend-service.yaml Dr Ganesh Neelakanta Iyer 124
  • 125. Creating the frontend service • Query the list of Services to verify that the frontend Service is running kubectl get services Dr Ganesh Neelakanta Iyer 125
  • 126. Viewing the Frontend Service via NodePort • If you deployed this application to Minikube or a local cluster, you need to find the IP address to view your Guestbook • Run the following command to get the IP address for the frontend Service minikube service frontend --url Dr Ganesh Neelakanta Iyer 126
  • 127. Go to a browser and type that URL Dr Ganesh Neelakanta Iyer 127
  • 128. Viewing the Frontend Service via LoadBalancer • If you deployed the frontend-service.yaml manifest with type: LoadBalancer you need to find the IP address to view your Guestbook • Run the following command to get the IP address for the frontend Service kubectl get service frontend Dr Ganesh Neelakanta Iyer 128
  • 129. Scale the Web Frontend • Scaling up or down is easy because your servers are defined as a Service that uses a Deployment controller • Run the following command to scale up the number of frontend Pods: kubectl scale deployment frontend --replicas=5 • Query the list of Pods to verify the number of frontend Pods running: kubectl get pods Dr Ganesh Neelakanta Iyer 129
  • 130. Summary • Kubernetes can help you – Create clusters – Deploy applications – Scale your business Dr Ganesh Neelakanta Iyer 130
  • 131.
  • 132.
  • 133. Dr Ganesh Neelakanta Iyer ni_amrita@cb.amrita.edu ganesh.vigneswara@gmail.com GANESHNIYER