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 the advantages of • Containerization, Continuous Integration/Delivery, DevOps, Cloud Computing and Microservices. It provides much of the simplicity of • PaaS with the flexibility of IaaS , and enables portability across infrastructure providers. Docker is the most common container • runtime used in K8s, but it also supports other runtimes. [1] 3
CaaS Concepts
CaaS Concepts Provides a complete container environment for deploying and • managing containers , applications and clusters . Container Orchestration lies at the heart of container • platforms. Focus is on creating the app containers and maintaining them in • the future. 5 [2]
Developer Responsibility
Developer Responsibility K8s Application Code Application Code Application Code Application Code Data Store Data Store Data Store Data Store Runtime / Middleware Runtime / Middleware Runtime / Middleware Runtime / Middleware Containers Containers Containers Containers Operating System Operating System Operating System Operating System Virtualization Virtualization Virtualization Virtualization Hardware Hardware Hardware Hardware IaaS CaaS PaaS FaaS Cloud Native Platform Scope 7
K8s Components
K8s Componenets A cluster is a logical unit, consisting of one Master node and 1..n Worker nodes. Worker Node Master Node Worker Node 9
K8s Componenets The Master Node is the server that is responsible for the Kubernetes management tasks. Worker Node Master Node Worker Node 10
K8s Componenets Worker Nodes are the worker machines and are managed by the master components. Worker Node Master Node Worker Node 11
K8s Componenets The scheduler's main responsibility is to place the containers on the workers according to various policies, metrics, and resource requirements. Worker Node Master Node Scheduler Worker Node 12
K8s Componenets The controller manager is responsible for reconciling the state of the cluster with the desired state, as specified via the API. Worker Node Master Node Sheduler Controller-manager Worker Node 13
K8s Componenets The API server exposes a highly-configurable REST interface to all of the Kubernetes resources. Worker Node Master Node Sheduler API Controller-manager Worker Node 14
K8s Componenets The kubelet is responsible for communicating with the master services. Worker Node Kubelet Master Node Sheduler API Controller-manager Worker Node Kubelet 15
K8s Componenets The Docker engine is the container host that creates and runs Docker containers. Worker Node Kubelet Master Node Docker Sheduler API Controller-manager Worker Node Kubelet Docker 16
K8s Componenets The kube-proxy is in charge of managing network connectivity to the containers. Worker Node Kubelet Kube-proxy Master Node Docker Sheduler API Controller-manager Worker Node Kubelet Kube-proxy Docker 17
K8s Componenets 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. Worker Node Kubelet Kube-proxy Master Node Docker Sheduler API Controller-manager Worker Node Kubelet Kube-proxy Docker 18
K8s Basics Introduction (Usecase)
K8s Componenets The desired state exists in the Deployment, which contains the configuration that you feed to the cluster. Worker Node Master Node Kubelet Kube-proxy Sheduler API Docker Controller-manager Deployments Worker Node Kubelet Kube-proxy Docker 20
K8s Componenets The first fundamental piece inside this deployment is the Pod. Worker Node Master Node Kubelet Kube-proxy Sheduler API Docker Controller-manager Deployments Worker Node Pod1 Kubelet Kube-proxy Docker 21
K8s Componenets Within a Pod, there can be one or more running Containers. Worker Node Master Node Kubelet Kube-proxy Sheduler API Docker Controller-manager Deployments Worker Node Pod1 Kubelet Kube-proxy - ContImg1 - ContImg2 Docker 22
K8s Componenets In order to specify how many Pods will be run, a ReplicaSet needs to be defined. Worker Node Master Node Kubelet Kube-proxy Sheduler API Docker Controller-manager Deployments Worker Node Pod1 Kubelet Kube-proxy - ContImg1 - ContImg2 Docker ReplicaSet -> 3 23
K8s Componenets Let us define another Pod with 2 instances. Worker Node Master Node Kubelet Kube-proxy Sheduler API Docker Controller-manager Deployments Worker Node Pod1 Kubelet Kube-proxy - ContImg1 - ContImg2 Docker ReplicaSet -> 3 Pod2 - ContImg3 ReplicaSet -> 2 24
K8s Componenets 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. Worker Node Master Node Kubelet Kube-proxy Sheduler API Docker Controller-manager Worker Node Deployments Deployment Pod1 Pod1 Kubelet Kube-proxy - ContImg1 - ContImg1 - - ContImg2 ContImg2 Docker ReplicaSet -> 3 ReplicaSet -> 3 Pod2 Pod2 - ContImg3 - ContImg3 ReplicaSet -> 2 ReplicaSet -> 2 25
K8s Componenets Worker Node Master Node Kubelet Kube-proxy Sheduler API Docker Controller-manager P1R1 P1R2 Worker Node Deployments Pod1 Kubelet Kube-proxy - ContImg1 - ContImg2 Docker ReplicaSet -> 3 Pod2 P1R3 - ContImg3 ReplicaSet -> 2 26
K8s Componenets Worker Node Master Node Kubelet Kube-proxy Sheduler API Docker Controller-manager P1R1 P1R2 P2R1 Worker Node Deployments Pod1 Kubelet Kube-proxy - ContImg1 - ContImg2 Docker ReplicaSet -> 3 Pod2 P1R3 P2R2 - ContImg3 ReplicaSet -> 2 27
K8s Componenets So, at any point in time, the master services are responsible for making sure that the fed configuration is running on the worker nodes. Worker Node Master Node Kubelet Kube-proxy Sheduler API Docker Controller-manager P1R1 P1R2 P2R1 Worker Node Deployments Pod1 Kubelet Kube-proxy - ContImg1 - ContImg2 Docker ReplicaSet -> 3 Pod2 P1R3 P2R2 - ContImg3 ReplicaSet -> 2 28
K8s Componenets What happens if one worker node is lost?! Worker Node Master Node Kubelet Kube-proxy Sheduler API Docker Controller-manager P1R1 P1R2 P2R1 Worker Node Deployments Pod1 Kubelet Kube-proxy - ContImg1 - ContImg2 Docker ReplicaSet -> 3 Pod2 P1R3 P2R2 - ContImg3 ReplicaSet -> 2 29
K8s Componenets The kubelet services will notify us about the changes and the scheduler will instantiate the lost pods again to reach the desired state. Worker Node Master Node Kubelet Kube-proxy Sheduler API Docker Controller-manager P1R1 P1R2 P2R1 P1R3 P2R2 Deployments Pod1 - ContImg1 - ContImg2 ReplicaSet -> 3 Pod2 - ContImg3 ReplicaSet -> 2 30
K8s Basics Pods
K8s Basics: Pods A pod is an abstract layer which synthesizes a certain amount of • Docker containers that are meant to run together´. It represents the smallest unit of deployment , i.e., 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. Pods provide two kinds of shared resources for their constituent • containers: networking and storage . Containers within a pod share the same IP address, port space, • hostname and storage, and can find each other via localhost . app app runtime runtime 32
K8s Basics Deployments
K8s Basics: Deployments A deployment is a description of the desired condition of a • particular microservice (number of instances, port forwarding, docker image …) ReplicaSets are (usually) combined with pods when defining the • deployment A ReplicaSet ensures that a specified number of pod replicas are • running at any given time, thus ReplicaSets enable pods to scale horizontally deployment replica set replica set v2 pod pod v2 app app app app runtime runtime runtime runtime 34
K8s Basics Services
Apps - Deployment
Apps – Deployment app app runtime app Dockerfile runtime base runtime container 37
Apps – Deployment service/ingress deployment endpoint replica set replica set v2 kubectl run pod pod v2 pod v2 app app app app runtime runtime runtime runtime 38
Apps – Deployment Package your Run it locally on Deploy your app Push the image app into a your machine to the K8s to a registry „optional“ Cluster Docker image Deploy a new Scale your Scale your version of your Expose your app deployment deployment app „rolling to the internet automatically manually update“ 39
Apps – Deployment “Summary” config.yml --- --- --- UI todo Postgres todoui.service.yml postgres.yml todobackend.yml todoui.yml postgres.service.yml todobackend.service.yml 40
K8s cluster networking Intra pod communication
Recommend
More recommend