## Containers Orchestration  You just deployed your ML model in production **on one machine** #### Questions Suppose I have a large pool of machines available * How do I **deploy my container on several machines ?** * How do I **put the right containers at the right spot ?** * How do I **scale (up and down) to demand ?** * How do I **expose the http endpoints ?** * How do I **manage failure of containers ?** * How do I **update my model without downtime** ### In reality, it's much more complex...  ### Orchestration
#### The next step  #### Orchestration - containers are a lightweight mechanism for isolating an application's environment - specify the system configuration and libraries to install - avoid conflicts with other applications - each application as a container image which can be executed reliably on any machine - place multiple workloads on the same physical machine or distributed over many machines - orchestration for fail cases of containers or machines - allow for updates without downtime by creating new containers ### Orchestration Design Principles - **Declarative** - describe ideal system state - **Distributed** - use multiple machines for scale & properly use each machine resources - **Microservice** - decouple applications into individual services - **Immutable** - Change image versions, not instances ### Examples... - Docker Swarm - CoreOS Fleet - [Apache Mesos](https://mesos.apache.org/) / [Marathon](https://github.com/mesosphere/marathon) ... and so many more !   ### Kubernetes ("Helmsman")   Kubernetes (or k8s) comes from Google's internal systems [Borg](https://github.com/SupaeroDataScience/DE/blob/master/readings/borg.pdf) It is open source now
and used... everywhere ? ### [Kubernetes](https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/)  Kubernetes manages your containers on a cluster of machine while taking care of - Creation, deletion, and movement of containers - Scheduling (match containers to machines by ressources etc.) - Scaling of containers - Serving of containers through unified endpoints - Monitoring and healing Kubernetes is part of [Cloud Native Computing Foundation](https://www.cncf.io/)  > As part of the Linux Foundation, we provide support, oversight and direction for fast-growing, cloud native projects, including Kubernetes, Envoy, and Prometheus. [Cloud Native Computing Foundation Landscape](https://landscape.cncf.io/)  [Cloud Native Computing Foundation Projects](https://landscape.cncf.io/)  😱 😱 😱 😱  🤗 🤗 🤗  Pods  Pods, Nodes  Endpoints  Updating  "Declarative" programming, cloud agnostic  "Declarative" programming : Welcome to YAML `kubectl apply -f deployment.yaml`  "Declarative" programming : Welcome to YAML `kubectl apply -f deployment.yaml` ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80 ```  Example:
GCP + k8s = ❤️   [comic](https://cloud.google.com/kubernetes-engine/kubernetes-comic/) Play with k8s