This document provides an overview of Kubernetes and microservices architectures. It discusses the differences between monolithic and microservices applications and the advantages and disadvantages of each. It then introduces Kubernetes, including its origins at Google, components like the master, nodes, and objects. It covers management techniques like imperative commands, imperative object configuration, and declarative object configuration. Finally, it discusses key Kubernetes concepts like pods, services, and deployments. It also compares manually hosting a Kubernetes cluster to using Azure Kubernetes Service.
4. Monolith
The “Good”
● Fewer moving parts enables easy
deployment
The “Bad”
● Longer Release cycles
● Update to one functionality requires
redeployment of the entire codebase
6. The biggest questions ever asked (some of)
● Is the universe deterministic?
● What happens after you die?
7. The biggest questions ever asked (some of)
● Is the universe deterministic?
● What happens after you die?
● What is life?
8. The biggest questions ever asked (some of)
● Is the universe deterministic?
● What happens after you die?
● What is life?
● What is a microservice?
9.
10. 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
11. 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
16. ● 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
17. K8s: big picture view
● The Master is responsible for
managing the cluster
18. 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.
28. K8s: master 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.
29. K8s: master 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.
31. 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
37. 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.
38. 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
39. 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)
40. 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/
41. 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
43. 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
44. 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
48. 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
49. Service overview
● Service is an abstraction which defines a logical
set of Pods and a policy by which to access
them
50. Service overview
● Service is an abstraction which defines a logical
set of Pods and a policy by which to access
them
● The set of Pods targeted by a Service is
(usually) determined by a Label Selector
51. 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.
53. Self-hosting K8s cluster
Manually install master
and worker nodes
Need to consider master HA,
adding additional worker
nodes, patching, updates, ...
54. 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
Notas del editor
Master components provide the cluster’s control plane. Master components make global decisions about the cluster (for example, scheduling), and detecting and responding to cluster events (starting up a new pod when a replication controller’s ‘replicas’ field is unsatisfied).
Master components can be run on any machine in the cluster. However, for simplicity, set up scripts typically start all master components on the same machine, and do not run user containers on this machine.
It is the brain to the master and is front-end to the master or control plane. Kube-apiserver implements the RESTful API and consumes json via a manifest file. Manifest files declare the state of the app like a record of intent and are validated and deployed on the cluster. It exposes an endpoint (by default on port 443) so that kubectl (command line utility) can issue commands/queries and run on the master.
It provides persistent storage and is stateful. It uses etcd. It is distributed, consistent and watchable. etcd – etcd is open source distributed key-value store that serves as the backbone of distributed systems by providing a canonical hub for cluster coordination and state management. Kubernetes uses etcd as the “source of truth” for the cluster. It takes care of storing and replicating data used by Kubernetes across the entire cluster. It is written in Go language and uses Raft protocol, which helps etcd in recovering from hardware failure and network partitions.
This is the process that watches API-server for new pods and assigns workloads to specific nodes in the cluster. It is responsible for tracking resource utilization on each host to make sure that workloads are not scheduled in excess of the available resources.
Kubernetes controller manager is a daemon that implants the core control loops shipped with Kubernetes. It is the controller of controllers. It watches the shared state of the cluster through the API server and makes changes attempting to move the current state towards the desired state. Examples of controllers that ship with Kubernetes today are the replication controller, endpoints controller, namespace controller, and service accounts controller. At the point when a change is seen, the controller reads the new information and implements the procedure that fulfills the desired state. This can involve scaling an application up or down, adjusting endpoints, and so forth. A Replication controller provides a pod template for creating any number of pod copies. It provides logic for scaling pod up or down. It can also be used for rolling deployments.
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
Node components run on every node, maintaining running pods and providing the Kubernetes runtime environment.
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
the main Kubernetes agent on the node
registers node with the cluster
watches API server for work assignment
instantiate pods for carrying out the work
reports back to master
exposes endpoint on port-10255. It lets you inspect the specs of a Kubelet.