AKS: Kubernetes e Azure
alla massima potenza
Alessandro Melchiori // @amelchiori
Monolith vs
microservice(s)
Monolith
The Good
● Monolith can be good when you are
starting out
● Fewer moving parts enables easy
deployment
Monolith
The “Bad”
● When your application (or company)
grows, monolith begin slowing you
down
Challenges with monolithic software
Challenges with monolithic software
● Difficult to scale
Challenges with monolithic software
● Difficult to scale
● Architecture is hard to maintain and evolve
○ Es: too much software coupling
Challenges with monolithic software
● Difficult to scale
● Architecture is hard to maintain and evolve
○ Es: too much software coupling
● Long build/test/release cycle
○ Update to one functionality requires redeployment of the entire codebase
Challenges with monolithic software
● Difficult to scale
● Architecture is hard to maintain and evolve
○ Es: too much software coupling
● Long build/test/release cycle
○ Update to one functionality requires redeployment of the entire codebase
● Operations is a nightmare
Other options?
The biggest questions ever asked (some of)
● What happens after you die?
The biggest questions ever asked (some of)
● What happens after you die?
● What is life?
The biggest questions ever asked (some of)
● What happens after you die?
● What is life?
● What is a microservice?
What are microservices
service -oriented
architecture composed of
loosely coupled elements
that have bounded context
Adrian Cockcroft
What are microservices
service -oriented
architecture composed of
loosely coupled elements
that have bounded context
Adrian Cockcroft
Services talk with each other over the
network
What are microservices
service -oriented
architecture composed of
loosely coupled elements
that have bounded context
Adrian Cockcroft
You can update the services
independently; updating one service
doesn’t require changing any other
service
What are microservices
service -oriented
architecture composed of
loosely coupled elements
that have bounded context
Adrian Cockcroft
Self-contained; you can update the
code without knowing anything about
the internals of other microservices
Anatomy of a (micro)service
Data Store App. / Logic
Public API
● Http
● gRPC
● Messages
● ...
Anatomy of a (micro)service
Service A Service B
Public API
Public API
Anatomy of a (micro)service
Service A Service B
Public API
Public API
Anatomy of a (micro)service
Service A Service B
Public API
Public API
Anatomy of a (micro)service
Service A
Public API
Version 1.0.0
storeRestaurant(id, name)
Anatomy of a (micro)service
Service A
Public API
Version 1.0.0
storeRestaurant(id, name)
Version 1.1.0
storeRestaurant(id, name)
storeRestaurant(id, name, metadata)
addReview(restaurantId, rating, comments)
Anatomy of a (micro)service
Service A
Public API
Version 1.0.0
storeRestaurant(id, name)
Version 1.1.0
storeRestaurant(id, name)
storeRestaurant(id, name, metadata)
addReview(restaurantId, rating, comments)
Version 2.0.0
storeRestaurant(id, name, metadata)
addReview(restaurantId, rating, comments)
Microservice architecture
The “Good”
● An application is sum of its
components
● Better fault isolation
● Components can be spread across
multiple servers
Microservice architecture
The “Good”
● An application is sum of its
components
● Better fault isolation
● Components can be spread across
multiple servers
The “Bad”
● Many components, many moving
parts
● Difficult to manage
inter-communication
● Manual management can be
difficult
Microservice architecture
The “Good”
● An application is sum of its
components
● Better fault isolation
● Components can be spread across
multiple servers
The “Bad”
● Many components, many moving
parts
● Difficult to manage
inter-communication
● Manual management can be
difficult
Welcome
Kubernetes
Kubernetes
Greek for “Helmsman” < the person who steers a ship
Kubernetes
Greek for “Helmsman” < the person who steers a ship
K8s
Greek for “Helmsman” < the person who steers a ship
● Born in Google
● Donated to CNCF in 2014
● Open source (Apache 2.0)
● v1.0 July 2015
● Written in Go/Golang
● Code is on GitHub (where otherwise?)
K8s: some infos
K8s: the big picture view
K8s: big picture view
● The Master is responsible for
managing the cluster
K8s: big picture view
● The Master is responsible for
managing the cluster
● A node is a VM or a physical
computer that serves as a worker
machine in a Kubernetes cluster.
Master(s)
The K8s control plane
K8s: master components
K8s: master components
kube-apiserver
Component on the master that exposes the
Kubernetes API. It is the front-end for the
Kubernetes control plane.
It is designed to scale horizontally
K8s: master components
etcd
Consistent and highly-available key value
store used as Kubernetes’ backing store for
all cluster data.
K8s: master components
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.
K8s: master components
kube-controller-manager
Component on the master that runs
controllers:
● Node controller
● Replication controller
● Endpoints controller
● Service Account & Token controller
Node(s)
The K8s workers
K8s: node components
K8s: node components
kubelet
An agent that runs on each node in the
cluster. It makes sure that containers are
running in a pod.
K8s: node components
kube-proxy
It is like the network brain of the node. It is
a network proxy which reflects Kubernetes
networking services on each node.
K8s: node components
Container runtime
It’s the software that is responsible for
running containers. Kubernetes supports
several runtimes: Docker, rkt, runc and any
OCI runtime-spec implementation.
K8s objects
K8s objects overview
Kubernetes contains a number of abstractions that represent the state of your
system: deployed containerized applications and workloads, their associated
network and disk resources, and other information about what your cluster is
doing.
These abstractions are represented by objects in the Kubernetes API
K8s objects
Basic Kubernetes objects:
● Pod
● Service
● Volume
● Namespace
K8s objects
Basic Kubernetes objects:
● Pod
● Service
● Volume
● Namespace
Higher-level abstraction (controllers):
● ReplicaSet
● Deployment
● StatefulSet
● DaemonSet
● Job
Pods, Services and
Deployment
Pod overview
● Is the basic building block of Kubernetes
● Represents a running process on the
cluster
● Consists of either a single container or a
small number of containers that are
tightly coupled and that share resources
Pod phases
Pods are mortal
The phase of a Pod is a simple, high-level
summary of where the Pod is in its lifecycle:
● Pending
● Running
● Succeeded
● Failed
● Unknown
Service overview
P frontend
10.0.0.12
P frontend
10.0.0.83
P frontend
10.0.0.25
P frontend
10.0.0.39
P backend
10.0.0.41
P backend
10.0.0.44
Service overview
P frontend
10.0.0.12
P frontend
10.0.0.83
P frontend
10.0.0.25
P frontend
10.0.0.39
P backend
10.0.0.41
P backend
10.0.0.44
Service overview
P frontend
10.0.0.12
P frontend
10.0.0.83
P frontend
10.0.0.25
P frontend
10.0.0.39
P backend
10.0.0.41
P backend
10.0.0.81
Service overview
P frontend
10.0.0.12
P frontend
10.0.0.83
P frontend
10.0.0.25
P frontend
10.0.0.39
P backend
10.0.0.41
P backend
10.0.0.44
P
DNS:
be.myservice
10.0.0.27
Deployment overview
● It provides declarative updates for Pods
and ReplicaSets.
● You describe a desired state in a
Deployment object, and the Deployment
controller changes the actual state to
the desired state at a controlled rate.
Declarative model
&
Desired state
Management techniques
The kubectl command-line tool supports several different ways to create and
manage Kubernetes objects:
● Imperative commands
● Imperative object configuration
● Declarative object configuration
Imperative commands
The simplest way to get started or to run a one-off task in a cluster.
kubectl run nginx --image nginx
Imperative commands
Pro:
● Commands are simple, easy to
learn and easy to remember.
● Commands require only a single
step to make changes to the
cluster
Cons:
● Commands do not integrate with
change review processes.
● Commands do not provide an
audit trail associated with
changes.
Imperative object configuration
In imperative object configuration, the kubectl command specifies the operation
(create, replace, etc.), optional flags and at least one file name.
The file specified must contain a full definition of the object in YAML or JSON
format.
kubectl create -f nginx.yaml
Imperative object configuration
Pro:
● Object configuration can be stored
in a source control system such as
Git (vs. imperative commands)
● It’s simpler and easier to
understand (vs. declarative object
configuration)
Cons:
● Object configuration requires basic
understanding of the object
schema (vs. imparative commands)
● It works best on files, not
directories (vs. declarative object
configuration)
● Updates to live objects must be
reflected in configuration files, or
they will be lost during the next
replacement (vs. declarative object
configuration)
Declarative object configuration
Using declarative object configuration, a user operates on object configuration
files stored locally, however the user does not define the operations to be taken
on the files.
Create, update, and delete operations are automatically detected per-object by
kubectl.
kubectl apply -f configs/
Declarative object configuration
Pro:
● Changes made directly to live
objects are retained, even if they
are not merged back into the
configuration files
● It has better support for operating
on directories and automatically
detecting operation types
per-object
Cons:
● Declarative object configuration is
harder to debug
K8s + Azure = AKS
Self-hosting K8s cluster
Manually install master
and worker nodes
Need to consider master HA,
adding additional worker
nodes, patching, updates, ...
Azure Kubernetes Service
● Simplifies deployment, management and
operations of K8s
● Makes it quick and easy to deploy and manage
containerized applications without container
orchestration expertise
● Eliminates the burden of ongoing operations and
maintenance by provisioning, upgrading and scaling
resources on demand
Alessandro Melchiori
Software developer @ CodicePlastico
alessandro@codiceplastico.com
@amelchiori

AKS: k8s e azure

  • 1.
    AKS: Kubernetes eAzure alla massima potenza Alessandro Melchiori // @amelchiori
  • 2.
  • 3.
    Monolith The Good ● Monolithcan be good when you are starting out ● Fewer moving parts enables easy deployment
  • 4.
    Monolith The “Bad” ● Whenyour application (or company) grows, monolith begin slowing you down
  • 5.
  • 6.
    Challenges with monolithicsoftware ● Difficult to scale
  • 7.
    Challenges with monolithicsoftware ● Difficult to scale ● Architecture is hard to maintain and evolve ○ Es: too much software coupling
  • 8.
    Challenges with monolithicsoftware ● Difficult to scale ● Architecture is hard to maintain and evolve ○ Es: too much software coupling ● Long build/test/release cycle ○ Update to one functionality requires redeployment of the entire codebase
  • 9.
    Challenges with monolithicsoftware ● Difficult to scale ● Architecture is hard to maintain and evolve ○ Es: too much software coupling ● Long build/test/release cycle ○ Update to one functionality requires redeployment of the entire codebase ● Operations is a nightmare
  • 10.
  • 11.
    The biggest questionsever asked (some of) ● What happens after you die?
  • 12.
    The biggest questionsever asked (some of) ● What happens after you die? ● What is life?
  • 13.
    The biggest questionsever asked (some of) ● What happens after you die? ● What is life? ● What is a microservice?
  • 15.
    What are microservices service-oriented architecture composed of loosely coupled elements that have bounded context Adrian Cockcroft
  • 16.
    What are microservices service-oriented architecture composed of loosely coupled elements that have bounded context Adrian Cockcroft Services talk with each other over the network
  • 17.
    What are microservices service-oriented architecture composed of loosely coupled elements that have bounded context Adrian Cockcroft You can update the services independently; updating one service doesn’t require changing any other service
  • 18.
    What are microservices service-oriented architecture composed of loosely coupled elements that have bounded context Adrian Cockcroft Self-contained; you can update the code without knowing anything about the internals of other microservices
  • 19.
    Anatomy of a(micro)service Data Store App. / Logic Public API ● Http ● gRPC ● Messages ● ...
  • 20.
    Anatomy of a(micro)service Service A Service B Public API Public API
  • 21.
    Anatomy of a(micro)service Service A Service B Public API Public API
  • 22.
    Anatomy of a(micro)service Service A Service B Public API Public API
  • 23.
    Anatomy of a(micro)service Service A Public API Version 1.0.0 storeRestaurant(id, name)
  • 24.
    Anatomy of a(micro)service Service A Public API Version 1.0.0 storeRestaurant(id, name) Version 1.1.0 storeRestaurant(id, name) storeRestaurant(id, name, metadata) addReview(restaurantId, rating, comments)
  • 25.
    Anatomy of a(micro)service Service A Public API Version 1.0.0 storeRestaurant(id, name) Version 1.1.0 storeRestaurant(id, name) storeRestaurant(id, name, metadata) addReview(restaurantId, rating, comments) Version 2.0.0 storeRestaurant(id, name, metadata) addReview(restaurantId, rating, comments)
  • 26.
    Microservice architecture The “Good” ●An application is sum of its components ● Better fault isolation ● Components can be spread across multiple servers
  • 27.
    Microservice architecture The “Good” ●An application is sum of its components ● Better fault isolation ● Components can be spread across multiple servers The “Bad” ● Many components, many moving parts ● Difficult to manage inter-communication ● Manual management can be difficult
  • 28.
    Microservice architecture The “Good” ●An application is sum of its components ● Better fault isolation ● Components can be spread across multiple servers The “Bad” ● Many components, many moving parts ● Difficult to manage inter-communication ● Manual management can be difficult
  • 29.
  • 30.
    Kubernetes Greek for “Helmsman”< the person who steers a ship
  • 31.
    Kubernetes Greek for “Helmsman”< the person who steers a ship
  • 32.
    K8s Greek for “Helmsman”< the person who steers a ship
  • 33.
    ● Born inGoogle ● Donated to CNCF in 2014 ● Open source (Apache 2.0) ● v1.0 July 2015 ● Written in Go/Golang ● Code is on GitHub (where otherwise?) K8s: some infos
  • 34.
    K8s: the bigpicture view
  • 35.
    K8s: big pictureview ● The Master is responsible for managing the cluster
  • 36.
    K8s: big pictureview ● The Master is responsible for managing the cluster ● A node is a VM or a physical computer that serves as a worker machine in a Kubernetes cluster.
  • 37.
  • 38.
  • 39.
    K8s: master components kube-apiserver Componenton the master that exposes the Kubernetes API. It is the front-end for the Kubernetes control plane. It is designed to scale horizontally
  • 40.
    K8s: master components etcd Consistentand highly-available key value store used as Kubernetes’ backing store for all cluster data.
  • 41.
    K8s: master components kube-scheduler Componenton the master that watches newly created pods that have no node assigned, and selects a node for them to run on.
  • 42.
    K8s: master components kube-controller-manager Componenton the master that runs controllers: ● Node controller ● Replication controller ● Endpoints controller ● Service Account & Token controller
  • 43.
  • 44.
  • 45.
    K8s: node components kubelet Anagent that runs on each node in the cluster. It makes sure that containers are running in a pod.
  • 46.
    K8s: node components kube-proxy Itis like the network brain of the node. It is a network proxy which reflects Kubernetes networking services on each node.
  • 47.
    K8s: node components Containerruntime It’s the software that is responsible for running containers. Kubernetes supports several runtimes: Docker, rkt, runc and any OCI runtime-spec implementation.
  • 48.
  • 49.
    K8s objects overview Kubernetescontains a number of abstractions that represent the state of your system: deployed containerized applications and workloads, their associated network and disk resources, and other information about what your cluster is doing. These abstractions are represented by objects in the Kubernetes API
  • 50.
    K8s objects Basic Kubernetesobjects: ● Pod ● Service ● Volume ● Namespace
  • 51.
    K8s objects Basic Kubernetesobjects: ● Pod ● Service ● Volume ● Namespace Higher-level abstraction (controllers): ● ReplicaSet ● Deployment ● StatefulSet ● DaemonSet ● Job
  • 52.
  • 53.
    Pod overview ● Isthe basic building block of Kubernetes ● Represents a running process on the cluster ● Consists of either a single container or a small number of containers that are tightly coupled and that share resources
  • 54.
    Pod phases Pods aremortal The phase of a Pod is a simple, high-level summary of where the Pod is in its lifecycle: ● Pending ● Running ● Succeeded ● Failed ● Unknown
  • 55.
    Service overview P frontend 10.0.0.12 Pfrontend 10.0.0.83 P frontend 10.0.0.25 P frontend 10.0.0.39 P backend 10.0.0.41 P backend 10.0.0.44
  • 56.
    Service overview P frontend 10.0.0.12 Pfrontend 10.0.0.83 P frontend 10.0.0.25 P frontend 10.0.0.39 P backend 10.0.0.41 P backend 10.0.0.44
  • 57.
    Service overview P frontend 10.0.0.12 Pfrontend 10.0.0.83 P frontend 10.0.0.25 P frontend 10.0.0.39 P backend 10.0.0.41 P backend 10.0.0.81
  • 58.
    Service overview P frontend 10.0.0.12 Pfrontend 10.0.0.83 P frontend 10.0.0.25 P frontend 10.0.0.39 P backend 10.0.0.41 P backend 10.0.0.44 P DNS: be.myservice 10.0.0.27
  • 59.
    Deployment overview ● Itprovides declarative updates for Pods and ReplicaSets. ● You describe a desired state in a Deployment object, and the Deployment controller changes the actual state to the desired state at a controlled rate.
  • 60.
  • 61.
    Management techniques The kubectlcommand-line tool supports several different ways to create and manage Kubernetes objects: ● Imperative commands ● Imperative object configuration ● Declarative object configuration
  • 62.
    Imperative commands The simplestway to get started or to run a one-off task in a cluster. kubectl run nginx --image nginx
  • 63.
    Imperative commands Pro: ● Commandsare simple, easy to learn and easy to remember. ● Commands require only a single step to make changes to the cluster Cons: ● Commands do not integrate with change review processes. ● Commands do not provide an audit trail associated with changes.
  • 64.
    Imperative object configuration Inimperative object configuration, the kubectl command specifies the operation (create, replace, etc.), optional flags and at least one file name. The file specified must contain a full definition of the object in YAML or JSON format. kubectl create -f nginx.yaml
  • 65.
    Imperative object configuration Pro: ●Object configuration can be stored in a source control system such as Git (vs. imperative commands) ● It’s simpler and easier to understand (vs. declarative object configuration) Cons: ● Object configuration requires basic understanding of the object schema (vs. imparative commands) ● It works best on files, not directories (vs. declarative object configuration) ● Updates to live objects must be reflected in configuration files, or they will be lost during the next replacement (vs. declarative object configuration)
  • 66.
    Declarative object configuration Usingdeclarative object configuration, a user operates on object configuration files stored locally, however the user does not define the operations to be taken on the files. Create, update, and delete operations are automatically detected per-object by kubectl. kubectl apply -f configs/
  • 67.
    Declarative object configuration Pro: ●Changes made directly to live objects are retained, even if they are not merged back into the configuration files ● It has better support for operating on directories and automatically detecting operation types per-object Cons: ● Declarative object configuration is harder to debug
  • 68.
  • 69.
    Self-hosting K8s cluster Manuallyinstall master and worker nodes Need to consider master HA, adding additional worker nodes, patching, updates, ...
  • 70.
    Azure Kubernetes Service ●Simplifies deployment, management and operations of K8s ● Makes it quick and easy to deploy and manage containerized applications without container orchestration expertise ● Eliminates the burden of ongoing operations and maintenance by provisioning, upgrading and scaling resources on demand
  • 71.
    Alessandro Melchiori Software developer@ CodicePlastico alessandro@codiceplastico.com @amelchiori