Containers, Serverless and Functions in a nutshell Eugene Fedorenko
About me Eugene Fedorenko Senior Architect Flexagon adfpractice-fedor.blogspot.com @fisbudo
Agenda Containers Microservices Docker Kubernetes Container Native Development Platform Serverless Functions
Start
The Idea. DEV TEST PROD
The Idea. Virtual Machine
Container A lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Containers share the host operating system rather than the hardware directly Way more lightweight than a VM Docker is the most popular implementation
Multilayered Application
Microservices and Containers Loans Deposits Forex
Microservices An architecture pattern decomposing vertically a monolith system into loosely coupled subsystems (microservices). Nothing more. The pattern doesn't dictate how it should be done technically. Just to highlight it: Microservices and Containers are not the same and totally independent. You can use Docker with a monolith app, and you can have several microservices without using Docker at all.
Architecture patterns. Evolution Monolith distributed horizontally on Prem/Cloud/Hybrid containerized horizontally Microservices distributed vertically and horizontally on Prem/Cloud/Hybrid containerized vertically and horizontally
Players (some of them) Player Cloud Container oriented service Serverless Project Oracle Oracle Cloud Oracle Container Cloud Service Oracle Container Native Application Development Platform Amazon AWS Elastic Container Service (ECS) Elastic Container Service for Kubernetes (EKS) Fn AWS Lambda Microsoft AZURE Azure Container Service (AKS) Azure Functions Google Google Cloud Google Kubernetes Engine (GKE) Google Cloud Functions Cloud Native Computing Foundation
Open Source Platforms and Projects Docker Container manager Docker Hub Docker Cloud Kubernetes
Docker Container Manager
Docker vs VM
Docker Hub Cloud based registry Public (free) Private Centralized resource for container images Repositories Automated Builds (based on Dockerfile) Docker CLI provides access to Docker Hub docker search, pull, login, push
Docker Cloud Built on top of Docker Hub Builds, Tests and Deploys Images Manages Infrastructure Serves as a facade Backed up by AWS, Azure, Digital Ocean, SoftLayer, Packet Operated with docker-cloud CLI API (Rest, Go, Python)
Agenda Containers Microservices Docker Kubernetes Container Native Development Platform Serverless Functions
Kubernetes Open Source platform (Google born) Orchestration engine for Ops A level of abstraction hiding the complexity of a hybrid environment (prem/cloud) Configuration properties Load balancing Scalability Security Visibility
Kubernetes Architecture Cluster. Set of physical or VMs. Masters and workers. Node. Worker. Minion. A physical or virtual machine. Docker is installed on it. Kubelet. Internal service running on each worker node and managed by a master node. Makes sure that everything works according to configuration files.
Kubectl. Kubernetes CLI. REST API. Dashboard. Kubernetes Architecture
Kubernetes Architecture Pod. Logical set of containers. A smallest deployable and scalable unit Replica set. Defines how many instances of a pod should be alive
Kubernetes Architecture Service. Logical set of pods with a stable ip/access rules and name. Has a lightweight internal load balancer. Internal, External
Container Native Application Development Platform
Oracle Cloud Infrastructure
Container Native Application Development Platform
FlexDeploy Pipeline
Architecture patterns. Evolution Location Prem -> Cloud -> Hybrid Platform Host -> VM -> Container Distribution Client -> Client/Sever -> 3-tier -> multi tier Composition Program + Platform -> Container Tendency decompose into small, independent, self-running pieces-of-work distributed across the globe
Process Oriented Architecture Functionality Data driven -> Process Oriented
Serverless A unit of work consumes resources only when it is used Function is a unit of work stateless serves one goal arguments (input) and result (output) Orchestration of independent pieces of work (functions as a service FaaS) Carrying state of the entire flow (program) Error handling Transaction management
Serverless Code centric paradigm. Hyde Infrastructure. Focus on coding resolving business problems and forget about infrastructure Everything is working on some computing resources Scalability Developers don't do anything for scaling. Scaling is handled automatically. Billing Don't pay for idle time Pay for milliseconds Utilization Many small pieces running for short time on same VM
Serverless There is no such thing as serverless computing. However, there is such a thing as dedicated serverless computing. Lucas Jellema. Oracle ACE Director. AMIS. CTO
AWS Lambda Azure Functions OpenWhisk Open Source / Apache Serverless Platforms Fn Open Source / Oracle container native OpenFaaS Open Source / Alex Ellis container native
Function (modern / Container-as-a-Function view) Static self-running piece-of-work wrapped into a container with everything it needs for its work code + platform stateless single purposed arguments (input) and result (output)
AWS Lambda (old generation) One of the first Function projects on the market The idea is: You have your code written with one of supported languages (limited list, binaries are preconfigured by AWS) Your code exposes some standardized API You upload your code (in a zip file) to AWS Lambda Basing on event (e.g. request on URL) AWS Lambda allocates resources for your code, invokes a function and releases the resource at the end The flow is orchestrated with AWS Step Functions Visual Flow designer
Fn Fn Platform (Fn Server and CLI) Based on Docker Functions are packaged into Docker images A custom Docker image can be used as a function A container lives as long as the function is being executed Fn FDK Libraries, annotations for standard input/output handling, configurations,... Polyglot. Supports a long list of languages (Java, Node.js, Python, Ruby, Go,...) Interaction with functions is based on Rest over HTTP or CLI Fn Flow Orchestration of function graph: state, transactions, exception handling Based on Java SE 8 API CompletionStage It's awesome! Like a good old Lisp. UI Dashboard visualizing flow executions
Fn Fn components are Docker containers Requires only Docker engine Can run on Kubernetes cluster
Function Flow Example Build Build Oracle Jet application Build a Docker Image (Nginx + Jet application) Push image to Docker Hub Deploy Accept image name and cluster name as parameters Deploy image to K8s cluster
Build Function Builder Docker image GIT client Node.js Ojet CLI efedorenko/ojetbuilder fn apps create ojetpipeline fn routes create ojetpipeline /build efedorenko/ojetbuilder:latest curl http://localhost:8080/r/ojetpipeline/build Docker Hub Automated Builds efedorenko/jetapplication
Deploy Function Deployer Docker image Kubectl K8s credentials K8s deployment profile (yaml) efedorenko/k8sdeployer fn routes create ojetpipeline /deploy efedorenko/k8sdeployer:latest curl http://localhost:8080/r/ojetpipeline/deploy -d "google-cloud-k8s-dev efedorenko/jetapplication:latest" efedorenko/jetapplication google-cloud-k8s-dev
Pipeline Function Flow public class PipelineFunction { public void pipeline(string cluster) { Flow fl = Flows.currentFlow(); FlowFuture<HttpResponse> pipeline = fl.invokefunction("./build", HttpMethod.POST, Headers.emptyHeaders(), input.getbytes()).thenapply(httpresponse::getbodyasbytes).thencompose((image) -> fl.invokefunction("./deploy", HttpMethod.POST, Headers.emptyHeaders(), (cluster + " " + new String(image)).getBytes())).exceptionally((err) -> { throw new RuntimeException("Pipeline error:" + err); }); } } fn deploy -app ojetpipeline curl http://localhost:8080/r/ojetpipeline/pipeline -d "google-cloud-k8s-dev"
Containers and Database Does not make sense for enterprise systems in terms of DevOps Data and PL/SQL code should be separated Containers are good for upper layers of the system (middleware, UI) Configuration properties are handled by the orchestration engine (Kubernetes, Docker swarms, etc.) Database may work in containers for benefits such as scalability, maintenance, abstraction from infrastructure, etc. Works perfectly for sample applications and test automation
Containers and SOA Containers/Kubernetes/Functions easily resolve Small loosely coupled services Handling of invocation traffic Process work flow Focus on implementing services and don't think about composing them
Q&A