You are on page 1of 41

Container Orchestration

Advanced Software Development Methodologies


(DAC - Oct 2021)
vigneswaris@cdac.in
Overview
❏ Introduction to YAML
❏ Introduction to Docker Swarm and Docker Stack
❏ Introduction to Kubernetes
❏ Creating Kubernetes cluster
❏ Creating service in Kubernetes
❏ Deploying an application using dashboard
❏ Introduction to Istio Service Mesh

2
Introduction to Orchestration
Container Orchestration
❏ Need - Scalability is an operational challenge
❏ Container orchestration is all about managing the lifecycle of
containers, especially in large, dynamic environments.
❏ Automating the deployment, management, scaling,
networking, and availability of containers

4
Container Orchestration
Software teams use container orchestration to control and
automate many tasks:
❏ Provisioning and deployment of containers
❏ Redundancy and availability of containers
❏ Scaling up or removing containers to spread application load
evenly across host infrastructure
❏ Movement of containers from one host to another if there is
a shortage of resources in a host, or if a host dies
5
Container Orchestration
Software teams use container orchestration to control and
automate many tasks:
❏ Allocation of resources between containers
❏ External exposure of services running in a container with the
outside world
❏ Load balancing of service discovery between containers
❏ Health monitoring of containers and hosts
❏ Configuration of an application in relation to the containers
running it
6
How does container orchestration work?
❏ When you use a container orchestration tool, like
Kubernetes or Docker Swarm, you typically describe the
configuration of your application in a YAML or JSON file,
depending on the orchestration tool.
❏ These configurations files are where you tell the
orchestration tool where to gather container images, how to
establish networking between containers, how to mount
storage volumes, and where to store logs for that container.

7
YAML
❏ Stands for Yet Another Markup Language
❏ Ain't Markup Language
❏ Data serialization language (Human readable)
❏ It is commonly used for configuration files
❏ JSON syntax is a basis of YAML version 1.2

8
Docker Orchestration tools
Kubernetes is an open source system for
managing containerized applications
across multiple hosts, providing basic
mechanisms for deployment,
maintenance, and scaling of applications.

Docker Swarm is a clustering and


scheduling tool for Docker containers.
With Swarm, IT administrators and
developers can establish and manage a
cluster of Docker nodes as a single virtual
system.
9
Docker Swarm
❏ Docker Swarm is a clustering and scheduling tool for Docker
containers.
❏ With Swarm, IT administrators and developers can establish
and manage a cluster of Docker nodes as a single virtual
system.
❏ Current versions of Docker include swarm mode for natively
managing a cluster of Docker Engines called a swarm.
❏ Use the Docker CLI to create a swarm, deploy application
services to a swarm, and manage swarm behavior.
10
Docker Swarm - Features
❏ Cluster management integrated with Docker Engine
❏ Decentralized design
❏ Scaling
❏ Desired state reconciliation
❏ Multi-host networking
❏ Service discovery
❏ Load balancing
❏ Secure by default
❏ Rolling updates
11
Docker Swarm - Architecture

12
Nodes
A node is an instance of the Docker engine participating in the
swarm.
❏ Manager Node
❏ Worker Node
Manager Node
To deploy your application to a swarm, you submit a service
definition to a manager node. The manager node dispatches units
of work called tasks to worker nodes. Manager nodes also
perform the orchestration and cluster management functions
13
Nodes
A node is an instance of the Docker engine participating in the
swarm.
❏ Manager Node
❏ Worker Node
Worker node
It receive and execute tasks dispatched from manager nodes. By
default manager nodes also run services as worker nodes, but
you can configure them to run manager tasks exclusively and be
manager-only nodes.
14
Nodes

15
Tasks
Task

❏ A task carries a Docker container and the commands to run


inside the container.
❏ It is the atomic scheduling unit of swarm.
❏ Manager nodes assign tasks to worker nodes according to the
number of replicas set in the service scale.

16
Services
Service

❏ A service is the definition of the tasks to execute on the


manager or worker nodes.
❏ When you create a service, you specify which container image
to use and which commands to execute inside running
containers.

17
Services & Tasks

18
Deployment using swarm
❏ To start the cluster
❏ docker swarm init --advertise-addr ip-address
❏ To view the token, used to join the cluster
❏ docker swarm join-token manager
❏ docker swarm join-token worker
❏ docker node ls
❏ To create Service
❏ docker service create --name "App-Container"
–replicas=2 <container-image>
19
Docker Stack
❏ A stack is a group of interrelated services that share
dependencies, and can be orchestrated and scaled together.
❏ A single stack is capable of defining and coordinating the
functionality of an entire application.
❏ A stack file is a file in YAML format, similar to a
docker-compose.yml file, that defines one or more services.
❏ Stacks are a convenient way to automatically deploy multiple
services that are linked to each other, without needing to
define each one separately.
20
Docker Stack
❏ Write docker-compose.yml file
❏ docker stack deploy -c docker-compose.yml <Stack Name>
❏ docker stack ls --- To the list the stacks
❏ docker stack services <Stack Name> --To list the services in
the stack
❏ docker stack ps <Stack Name> --- To list the containers/tasks
running

21
Compose Vs Stack
❏ The Docker Stack functionality, is included with the Docker
engine. You don’t need to install additional packages.
❏ docker-compose uses the Docker API to bring up containers
according to a specification and it will probably be deprecated
❏ Stack - YAML and JSON format

22
Kubernetes
❏ Kubernetes is an open-source platform created by Google for
container deployment operations, scaling up and down, and
automation across the clusters of hosts.
❏ This production-ready, enterprise-grade, self-healing
(auto-scaling, auto-replication, auto-restart, auto-placement)
platform is modular, and so it can be utilized for any
architecture deployment.
❏ Kubernetes also distributes the load amongst containers.
23
K8s - Terminologies
❏ Cluster: A cluster is a set of nodes with at least one master
node and several worker nodes (sometimes referred to
minions) that can be virtual or physical machines.
❏ Kubernetes master: The master manages the scheduling and
deployment of application instances across nodes, and the full
set of services the master node runs is known as the control
plane.. The master communicates with nodes through the
Kubernetes API server.
24
K8s - Terminologies
❏ Kubelet: Each Kubernetes node runs an agent process called
a kubelet that’s responsible for managing the state of the
node: starting, stopping, and maintaining application
containers based on instructions from the control plane.
A kubelet receives all of its information from the Kubernetes API
server.

25
K8s - Terminologies
Pods: The basic scheduling unit, which consists of one or more
containers guaranteed to be co-located on the host machine and
able to share resources.
❏ Each pod is assigned a unique IP address within the cluster,
allowing the application to use ports without conflict.
❏ You describe the desired state of the containers in a pod
through a YAML or JSON object called a PodSpec.
❏ These objects are passed to the kubelet through the API
server 26
K8s - Terminologies
Deployments, replicas, and ReplicaSets:
❏ A deployment is a YAML object that defines the pods and the
number of container instances, called replicas, for each pod.
❏ You define the number of replicas you want to have running in
the cluster via a ReplicaSet, which is part of the deployment
object.
❏ So, for example, if a node running a pod dies, the replica set
will ensure that another pod is scheduled on another
available node.
27
K8s - Architecture

28
Master Components
kube-apiserver
❏ Component on the master that exposes the Kubernetes API.
❏ It is the front-end for the Kubernetes control plane.
kube-scheduler
❏ Component on the master that watches newly created pods
that have no node assigned, and selects a node for them to
run on depending on the resource and policy constraints
defined. 29
Node Components
kubelet
❏ An agent that runs on each node in the cluster. It makes sure
that containers are running in a pod.
❏ The kubelet ensures that the containers are running and
healthy
kube-proxy
❏ kube-proxy enables the Kubernetes service abstraction by
maintaining network rules on the host and performing
connection forwarding.
30
Kubernetes using YAML

❏ There’s an easier and more useful way to use Kubernetes to


spin up resources outside of the command line:
❏ creating configuration files using YAML.

31
Creating Kubernetes cluster
❏ Kubernetes coordinates a highly available cluster of
computers that are connected to work as a single unit.

32
Creating Kubernetes cluster

https://kubernetes.io/docs/tutorials/kubernetes-basics/create-c
luster/cluster-interactive/

33
Why Services?
❏ Kubernetes Pods are mortal. ❏ A Service in Kubernetes is an
❏ Pods in fact have a lifecycle. abstraction which defines a logical set
❏ When a worker node dies, the of Pods and a policy by which to access
Pods running on the Node are them.
also lost. ❏ Services enable a loose coupling
❏ A ReplicaSet drive the cluster between dependent Pods.
back to desired state via creation ❏ A Service is defined using YAML
of new Pods to keep your (preferred) or JSON, like all Kubernetes
application running. objects.
❏ Need a way of automatically ❏ The set of Pods targeted by a Service is
reconciling changes among Pods usually determined by a LabelSelector
so that your applications continue ❏ Although each Pod has a unique IP
to function. address, those IPs are not exposed
outside the cluster without a Service. 34
Creating service in Kubernetes

https://kubernetes.io/docs/tutorials/kubernetes-basics/expose/expose-interactive/
35
Run Swarm and Kubernetes Interchangeably

36
Istio Service Mesh
❏ Service mesh network of microservices that make up
applications and the interactions between them.
❏ As a service mesh grows in size and complexity, it can become
harder to understand and manage.
❏ Ex: Access control, end-to-end authentication, discovery, load
balancing, failure recovery, metrics, and monitoring.
❏ Istio provides behavioral insights and operational control
over the service mesh as a whole, offering a complete solution
to satisfy the diverse requirements of microservice
applications. 37
Istio Service Mesh
❏ Istio makes it easy to create a network of deployed services
with load balancing, service-to-service authentication,
monitoring, and more, with few or no code changes in service
code.
❏ Add Istio support to services by deploying a special sidecar
proxy throughout your environment that intercepts all
network communication between microservices, then
configure and manage Istio using its control plane
functionality.
38
Istio - Architecture

39
Assignment
Kubernetes
❏ Deploy the website using Dashboard

41

You might also like