Slide 1

Slide 1 text

Towards micro-services architectures

Slide 2

Slide 2 text

Towards micro-services architectures

Slide 3

Slide 3 text

https://www.docker.com A Better Way to Build Apps

Slide 4

Slide 4 text

Let's get started - Docker for mac - Docker for windows

Slide 5

Slide 5 text

Dockerfile - Used by docker build - INSTRUCTION arguments - The first instruction must be `FROM` - FROM, RUN, CMD, COPY, ADD, - LABEL, ENV, WORKDIR, EXPOSE, … See https://github.com/docker-library/rails https://docs.docker.com/engine/reference/builder/

Slide 6

Slide 6 text

https://hub.docker.com You don’t have to reinvent the wheel (public vs private) 460K images

Slide 7

Slide 7 text

Monolithic vs Micro-services architectures Monolithic Microservices

Slide 8

Slide 8 text

What if I want to run multiple containers? Use docker-compose!
 You just need a docker-compose.yml

Slide 9

Slide 9 text

Towards micro-services architectures

Slide 10

Slide 10 text

https://kubernetes.io Kubernetes (k8s) is an open-source system for automating deployment, scaling, and management of containerized applications.
 
 It groups containers that make up an application into logical units for easy management and discovery. Kubernetes builds upon 15 years of experience of running production workloads at Google, combined with best-of-breed ideas and practices from the community. What is Kubernetes?

Slide 11

Slide 11 text

https://kubernetes.io Automatic binpacking Self-healing Horizontal scaling Service discovery and load balancing Automated rollouts and rollbacks Kubernetes Features

Slide 12

Slide 12 text

Kubernetes Master API UI CLI ETCD API SERVER SCHEDULER CONTROLLER The master is responsible for exposing the application program interface (API), scheduling the deployments and managing the overall cluster.

Slide 13

Slide 13 text

Kubernetes Master API UI CLI ETCD API SERVER SCHEDULER CONTROLLER The API server validates and configures data for the api objects which include pods, services, replication controllers, and others. The API Server services REST operations and provides the frontend to the cluster’s shared state through which all other components interact.

Slide 14

Slide 14 text

Kubernetes Master API UI CLI ETCD API SERVER SCHEDULER CONTROLLER The scheduler is a workload- specific function that significantly impacts availability, performance, and capacity. The scheduler needs to take into account individual and collective resource requirements, quality of service requirements, …

Slide 15

Slide 15 text

Kubernetes Master API UI CLI ETCD API SERVER SCHEDULER CONTROLLER The controller a controller is a control loop that watches the shared state of the cluster through the api server and makes changes attempting to move the current state towards the desired state.

Slide 16

Slide 16 text

Kubernetes Master API UI CLI ETCD API SERVER SCHEDULER CONTROLLER ETCD is a highly-available key value store which Kubernetes uses for persistent storage of all of its REST API objects.

Slide 17

Slide 17 text

Kubernetes Node POD POD POD POD ADDONS KUBELET DOCKER KUBE-PROXY FLUENTD POD

Slide 18

Slide 18 text

Kubernetes Components (simplified version)

Slide 19

Slide 19 text

https://kubernetes.io/docs/resources-reference/v1.5/#container-v1 Container name: nginx # Run the nginx:1.7.9 image image: nginx:1.7.9
 ports: - name: http containerPort: 8080 env: - name MY_ENV_VARIALBE value: my-value A simple container.*
 
 *Containers are only ever created within the context of a Pod. This is usually done using a Controller. See Controllers: Deployment, Job, or StatefulSet. or

Slide 20

Slide 20 text

https://kubernetes.io/docs/user-guide/pods/ Pod A Pod is a group of one or more containers that share the same hostname. Pod templates are pod specifications which are included in other objects, such as Replication Controllers, Jobs, and DaemonSets. Controllers use Pod Templates to make actual pods.

Slide 21

Slide 21 text

Labels and Selectors Labels are key/value pairs associated with kubernetes objects. They are used to query subsets of objects. Essential glue to associate one API object with other: - ReplicationController - Pods - Services - Pods - Pods - Nodes https://kubernetes.io/docs/user-guide/labels/ apiVersion: v1 kind: Pod metadata: name: nginx labels: type: frontend

Slide 22

Slide 22 text

https://kubernetes.io/docs/user-guide/replication-controller/ Replication Controller A ReplicationController ensures that a specified number of pod “replicas” are running at any one time. If there are too few, the ReplicationController will start more. Unlike manually created pods, the pods maintained by a ReplicationController are automatically replaced if they fail, get deleted, or are terminated. apiVersion: v1 kind: ReplicationController metadata: name: nginx spec: replicas: 3 selector: app: nginx template: metadata: name: nginx
 labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80

Slide 23

Slide 23 text

https://kubernetes.io/docs/user-guide/deployments/ Deployment A Deployment provides declarative updates for Pods and Replica Sets (the next- generation Replication Controller). You only need to describe the desired state in a Deployment object, and the Deployment controller will change the actual state to the desired state at a controlled rate for you. apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx spec: replicas: 3 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80

Slide 24

Slide 24 text

https://kubernetes.io/docs/user-guide/pods/ Pod, what’s the problem? Kubernetes Pods are mortal. They are born and when they die, they are not resurrected. While each pod gets its own IP address, even those IP addresses cannot be relied upon to be stable over time.

Slide 25

Slide 25 text

https://kubernetes.io/docs/user-guide/services/ Service A single pod or a replica set can be exposed to the internal or external consumers via Services. apiVersion: v1 kind: Service metadata: name: my-service spec:
 selector: name: nginx type: NodePort ports: - port: 8080 name: http

Slide 26

Slide 26 text

https://kubernetes.io/docs/user-guide/horizontal-pod-autoscaling/walkthrough/ Horizontal Pod Autoscaler Horizontal Pod Autoscaling (HPA) automatically scales the number of pods in a replication controller, deployment or replica set based on observed CPU utilization.

Slide 27

Slide 27 text

https://github.com/kubernetes/community/blob/master/contributors/design-proposals/horizontal-pod-autoscaler.md Horizontal Pod Autoscaler

Slide 28

Slide 28 text

https://github.com/kubernetes/minikube Minikube Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a VM on your laptop for users looking to try out Kubernetes or develop with it day-to-day.

Slide 29

Slide 29 text

https://github.com/kubernetes/dashboard Kubernetes Dashboard https://github.com/kubernetes/dashboard

Slide 30

Slide 30 text

References • Getting started with docker, the step by step tutorial with examples
 https://www.youtube.com/watch?v=Vyp5_F42NGs • Docker Containers and Kubernetes with Brian Dorsey
 https://www.youtube.com/watch?v=Fcb4aoSAZ98