# kubernetes in 5 minutes ---- ## Kubernetes is a container orchestrator ---- ## But it is a kind of magic: We specify the configuration of applications as our "desired state" and Kubernetes will try to deploy this configuration. And it will try to maintain it over time whatever happens. ![](https://i.imgur.com/qFIV54W.png) ---- ## Kubernetes gives us - Deployment automation - Fast scalability - Application upgrades and rollbacks - Ensure the stability of the applications - Limit the resources consumed by the applications - Hot adding and removing resources as nodes - Automatic provision of disk resources - Network and security management - ... --- ## A Kubernetes cluster has 2 kind of nodes: - Masters - Workers ---- The core of kubernetes (k8s cluster services) and its API live in each MASTER node ---- We could have a simple master or we could have a bunch of master nodes to ensure the high availability ---- The workers are the container hosts. Composed by: - A container engine (Most used is docker) - A service called kubelet to communicate with kubernetes ---- ![](https://i.imgur.com/HZm42j5.png) --- ## How do we specify what kubernetes has to do? ---- We could define a deployent in a YAML with at least these 3 things: - Some metadata to describe and classify the deployment - The image(s) for the container(s) (e.g. an image from the Apache docker) - And the number of replicas we want (we could choose more than one to have high capacity to answer request and guarantee high availability) ---- Additionally we usually add some of these: - Live probe tests - Environment variables ---- Example with 2 applications deployment ![](https://i.imgur.com/yqjPa4o.png) ---- Each replica is called a POD. A pod contains at least one container. But sometimes it has more, for instance to collect metrics ---- Sometimes we want to keep the state of the container and it's files, for instance for a DB service. Then we will use statefulsets and disk provision ---- In a statefullset we provision some disk space to store the application data. Kubernetes doesn't care where is it stored, only needs a [plugin called storage class](https://kubernetes.io/docs/concepts/storage/storage-classes/) to manage it. Could be Amazon, Azure or Google block stores, CephFS, cinder, or others. --- # How does Kubernetes do the job? Some Examples ---- ## A pod failure The POD (App 1) in the worker 2 has died. Kubernetes is going to create a new pod to mantain the number of replicas ![](https://i.imgur.com/wEqfiRL.png =500x) ---- ## A worker failure The worker 2 has died, kubernetes will create the PODs in an other worker ![](https://i.imgur.com/dxMNUwF.png =500x) ---- ## Deployment upgrade We need to update a deployment with a new image. Kubernetes will stop and re-create one pod every time to ensure that the service doesn't interrupt. If the creation of a POD fails all the process stops to allow investigating the problem without interruption of the service. ---- ![](https://i.imgur.com/w91EwwV.png =500x) step 1. Kubernetes creates a new Pod with the new image version ---- ![](https://i.imgur.com/M4cv1e2.png =500x) step 2 and 3. Kubernetes deletes the replaced pod and creates a new pod. ---- ![](https://i.imgur.com/cTY28eH.png =500x) step 4. Kubernetes deletes the last old pod --- by Ivan Lausuch SUSE Engineer
{"tags":"Presentations","slideOptions":{"theme":"solarized"}}
    525 views
   owned this note