Kubernetes
Matthias Haeussler Mirna Alaisami
Kubernetes Matthias Haeussler Mirna Alaisami Overview Overview - - PowerPoint PPT Presentation
Kubernetes Matthias Haeussler Mirna Alaisami Overview Overview Kubernetes is an open-source platform designed to automate deploying , scaling , and operating application containers . Kubernetes v1.0 was released in 2015. It utilizes
Matthias Haeussler Mirna Alaisami
3
designed to automate deploying, scaling, and operating application containers.
Containerization, Continuous Integration/Delivery, DevOps, Cloud Computing and Microservices.
PaaS with the flexibility of IaaS, and enables portability across infrastructure providers.
runtime used in K8s, but it also supports
[1]
managing containers, applications and clusters.
platforms.
the future.
5 [2]
7 Application Code
Data Store Runtime / Middleware Containers Virtualization Hardware
IaaS
Operating System Application Code Data Store Runtime / Middleware Containers Virtualization Hardware
CaaS
Operating System Application Code Data Store Runtime / Middleware Containers Virtualization Hardware
PaaS
Operating System Application Code Data Store Runtime / Middleware Containers Virtualization Hardware
FaaS
Operating System
K8s Cloud Native Platform Scope
9
Master Node Worker Node Worker Node
A cluster is a logical unit, consisting of one Master node and 1..n Worker nodes.
10
Master Node Worker Node Worker Node
The Master Node is the server that is responsible for the Kubernetes management tasks.
11
Master Node Worker Node Worker Node
Worker Nodes are the worker machines and are managed by the master components.
12
Master Node Worker Node Worker Node
The scheduler's main responsibility is to place the containers on the workers according to various policies, metrics, and resource requirements.
Scheduler
13
Master Node Worker Node Worker Node
The controller manager is responsible for reconciling the state of the cluster with the desired state, as specified via the API.
Sheduler Controller-manager
14
Master Node Worker Node Worker Node
The API server exposes a highly-configurable REST interface to all of the Kubernetes resources.
Sheduler Controller-manager API
15
Master Node Worker Node Worker Node
The kubelet is responsible for communicating with the master services.
Sheduler Controller-manager API Kubelet Kubelet
16
Master Node Worker Node Worker Node
The Docker engine is the container host that creates and runs Docker containers.
Sheduler Controller-manager API Kubelet Kubelet Docker Docker
17
Master Node Worker Node Worker Node
The kube-proxy is in charge of managing network connectivity to the containers.
Sheduler Controller-manager API Kubelet Kubelet Docker Docker Kube-proxy Kube-proxy
18
Master Node Worker Node Worker Node
So, in k8s we can enforce what is called "Desired state management“, which means that I can feed the cluster services with specific configuration, and those services will run the configuration as desired in my infrastructure.
Sheduler Controller-manager API Kubelet Kubelet Docker Docker Kube-proxy Kube-proxy
20
The desired state exists in the Deployment, which contains the configuration that you feed to the cluster.
Deployments Worker Node Worker Node
Kubelet Kubelet Docker Docker Kube-proxy Kube-proxy
Master Node
Sheduler Controller-manager API
21
The first fundamental piece inside this deployment is the Pod.
Deployments Pod1 Worker Node Worker Node
Kubelet Kubelet Docker Docker Kube-proxy Kube-proxy
Master Node
Sheduler Controller-manager API
22
Within a Pod, there can be one or more running Containers.
Deployments Pod1
Worker Node Worker Node
Kubelet Kubelet Docker Docker Kube-proxy Kube-proxy
Master Node
Sheduler Controller-manager API
23
In order to specify how many Pods will be run, a ReplicaSet needs to be defined.
Deployments Pod1
ReplicaSet -> 3 Worker Node Worker Node
Kubelet Kubelet Docker Docker Kube-proxy Kube-proxy
Master Node
Sheduler Controller-manager API
24
Deployments Pod1
ReplicaSet -> 3 Pod2
ReplicaSet -> 2
Let us define another Pod with 2 instances.
Worker Node Worker Node
Kubelet Kubelet Docker Docker Kube-proxy Kube-proxy
Master Node
Sheduler Controller-manager API
25
Worker Node Worker Node
Kubelet Kubelet Docker Docker Kube-proxy Kube-proxy
Master Node
Sheduler Controller-manager API
Deployment Pod1
ReplicaSet -> 3 Pod2
ReplicaSet -> 2
Taking the Deployment file and feeding it to the API, the master services will figure out how to schedule the pods on the workers, making sure that the specified number of instances is running.
Deployments Pod1
ReplicaSet -> 3 Pod2
ReplicaSet -> 2
26
Worker Node Worker Node
Kubelet Kubelet Docker Docker Kube-proxy Kube-proxy
Master Node
Sheduler Controller-manager API
Deployments Pod1
ReplicaSet -> 3 Pod2
ReplicaSet -> 2
P1R1 P1R2 P1R3
27
Worker Node Worker Node
Kubelet Kubelet Docker Docker Kube-proxy Kube-proxy
Master Node
Sheduler Controller-manager API
Deployments Pod1
ReplicaSet -> 3 Pod2
ReplicaSet -> 2
P1R1 P1R2 P1R3 P2R1 P2R2
28
Worker Node Worker Node
Kubelet Kubelet Docker Docker Kube-proxy Kube-proxy
Master Node
Sheduler Controller-manager API
Deployments Pod1
ReplicaSet -> 3 Pod2
ReplicaSet -> 2
P1R1 P1R2 P1R3 P2R1 P2R2
So, at any point in time, the master services are responsible for making sure that the fed configuration is running on the worker nodes.
29
Worker Node
Kubelet Docker Kube-proxy
Master Node
Sheduler Controller-manager API
Deployments Pod1
ReplicaSet -> 3 Pod2
ReplicaSet -> 2
P1R1 P1R2 P2R1
Worker Node
Kubelet Docker Kube-proxy P1R3 P2R2
What happens if one worker node is lost?!
30
Worker Node
Kubelet Docker Kube-proxy
Master Node
Sheduler Controller-manager API
Deployments Pod1
ReplicaSet -> 3 Pod2
ReplicaSet -> 2
P1R1 P1R2 P2R1
The kubelet services will notify us about the changes and the scheduler will instantiate the lost pods again to reach the desired state.
P1R3 P2R2
Docker containers that are meant to run together´.
instance of an application in Kubernetes, which might consist of either a single container or a small number of containers that are tightly coupled.
containers: networking and storage.
hostname and storage, and can find each other via localhost.
32
runtime app runtime app
particular microservice (number of instances, port forwarding, docker image …)
deployment
running at any given time, thus ReplicaSets enable pods to scale horizontally
34
runtime app runtime app
pod
replica set runtime app runtime app
pod v2
replica set v2 deployment
37
Dockerfile runtime app app runtime
base container
runtime app
38
kubectl run
service/ingress
endpoint
runtime app runtime app
pod
replica set runtime app
pod v2
replica set v2 deployment runtime app
pod v2
39
Run it locally on your machine „optional“ Push the image to a registry Deploy your app to the K8s Cluster Expose your app to the internet Scale your deployment manually Scale your deployment automatically Deploy a new version of your app „rolling update“ Package your app into a Docker image
40
todo Postgres UI postgres.yml todobackend.yml todoui.yml todobackend.service.yml postgres.service.yml todoui.service.yml
42
they can directly communicate with each other’s port on localhost.
pod has its own IP address, and when a container in the pod uses localhost, it applies to the pod's IP address only.
Pod1 Pod2
IP: 10.10.10.1 IP: 10.10.10.2 Node
Port:1234 Port:1234 Port:8080 Localhost
inside your cluster can access.
44
Service
K8s Cluster
Pod2 Pod3 Pod1
Node1 Node2
(NodePort).
traffic that is sent to the static port is forwarded to the service.
46
Service
K8s Cluster
Pod2 Pod3 Pod1 Traffic
Node1 Node2 Port: 30000 Port: 30000
route, are automatically created.
48
Traffic LoadBalancer Service Pod2 Pod3 Pod1
Node1 Node2 K8s Cluster
1. https://i2.wp.com/thepracticalsysadmin.com/wp- content/uploads/2018/05/k8s1.png?ssl=1 2. https://www.slideshare.net/KarlIsenberg/container-
3. https://medium.com/@odedia/comparing-kubernetes-to-pivotal- cloud-foundry-a-developers-perspective-6d40a911f257 4. https://res.cloudinary.com/dukp6c7f7/image/upload/f_auto,fl_los sy,q_auto/s3-ghost/2016/06/o7leok.png 5. https://cdn-images- 1.medium.com/max/1200/1*NMYJ6pN61RsOwzQUDXgg1w.png, https://www.blablacar.com/
50
6. https://www.01net.it/wp- content/uploads/sites/14/2016/04/Huawei-logo-2015.jpg, https://www-file.huawei.com/-/media/corporate/pdf/press- center/media-kit/huawei_fact_sheet_2015_en.pdf 7. https://www.signavio.com/wp-content/uploads/2013/03/Logo- Zalando-WEB1.png?w=480&h=160&zc=2, http://tech.eu/features/339/inside-zalando/ 8. https://istio.io/img/logo.png 9. https://cdn-images- 1.medium.com/max/1200/1*fWtVse6DItxvOBowU85Www.png
51
Novatec Consulting GmbH
Dieselstraße 18/1 D-70771 Leinfelden-Echterdingen
info@novatec-gmbh.de www.novatec-gmbh.de
Senior Managing Consultant
Matthias Haeussler
matthias.haeussler@novatec-gmbh.de Consultant
Mirna Alaisami
Mirna.Alaisami@novatec-gmbh.de