Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Going serverless with Fn project, Fn Flow and Kubernetes

Fn Project is a container native, easy to use serverless platform developed by Oracle. With Fn flow, the platform provides a powerful flow engine to build long-running, reliable and scalable functions and to orchestrate processes between functions. Deployed on Kubernetes you get a high scaling solution to build serverless applications capable of handling even complex business scenarios.
In this talk I will give a short introduction to Serverless, FaaS and Fn project, you will see how to deploy it in Kunernetes and how to integrate it with your existing applications.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to comment

Going serverless with Fn project, Fn Flow and Kubernetes

  1. 1. # BaselOne18
  2. 2. #BaselOne18 Going serverless with Fn project, Fn Flow and Kubernetes
  3. 3. #BaselOne18 About me • Andy MoncsekAndy Moncsek • Principal Consultant @ TrivadisPrincipal Consultant @ Trivadis • Java, middleware, container, architectureJava, middleware, container, architecture • Andy.Moncsek@trivadis.comAndy.Moncsek@trivadis.com • Twitter: @AndyAHCPTwitter: @AndyAHCP
  4. 4. #BaselOne18 Agenda • Introduction to Serverless • Fn project • Fn Flow • Run / deploy to Kubernetes • Conclustion
  5. 5. #BaselOne18 INTRODUCTION TO SERVERLESS
  6. 6. #BaselOne18 Classification Infrastruct ure Platform (IaaS) Container Platform (CaaS) Application Platform (PaaS) Function Platform (FaaS) Software Platform (SaaS) on-prem • OpenStack • vSphere • Azure Stack VMs • Kubernetes • DC/OS • Docker Data Center • CloudFoundry • OpenShift • WaveMaker • OpenWhisk • Fn-project • Iron.io BYO hoste • AWS EC2 • GCE • Azure VMs • GKE • ECE • ACE • Heroku • PCF • Jelastic • AWS-Lambda • GCF • Azure-functions • SalesForce • Oracle • SAP
  7. 7. #BaselOne18 FaaS  what are functions? In mathematics, a function is a relation between a set of inputs and a set of permissible outputs with the property that each input is related to exactly one output. - Wikipedia
  8. 8. #BaselOne18 FaaS  what are functions? • Functions are a small piece of code doing one thing • As a Service means: – no complicated set-up & packaging – the system takes care of provisioning, scaling, patching, maintaining • Each function scales independently – no complicated concurrency
  9. 9. #BaselOne18 What is Serverless? • Next Level of abstraction – in infrastructure (after PaaS, CaaS) – in operations, including provisioning, scaling, patching • FaaS is the compute component in a serverless architecture
  10. 10. #BaselOne18 What is Serverless? Flexibility Abstraction functions apps containers VMs
  11. 11. #BaselOne18 Why you should run Serverless (in cloud & on- prem?) - Easier: better first time experience, think about code, not the infrastructure - Faster: to deploy, iterate, innovate - Capacity planning: executed when needed, auto scaling & management, over planning, irregular workloads, pay per use
  12. 12. #BaselOne18 THE FN-PROJECT introduction
  13. 13. #BaselOne18 Introducing the Fn-project  Open-source serverless compute platform  Easy for new users, low level controls for advanced users  Based on Docker ecosystem  Deploy to Kubernetes, Swarm, Mesos  Strong enterprise focus (security, scalability, observability, etc.)
  14. 14. #BaselOne18 Fn-project components 1. Fn Server is the Functions-as-a-Service system 2. Fn FDK’s, the develoment kits for diferent langages 3. Fn Flow allows developers to build and orchestrate higher level workflows of functions 4. The Fn Load Balancer (Fn LB) allows operators to deploy clusters of Fn servers and route traffic to them intelligently
  15. 15. #BaselOne18 Fn function  Chunk of code wrapped into a container  Input via STDIN  Output to STDOUT  Logs to STDERR  The Fn Server handles everything else
  16. 16. #BaselOne18 Fn function  Any container can be a deployed as Fn function Reuse oss librariers as functions  Fn functions are containers with known traits: Short running, stateless, single purpose, self- name: example/resize512 version: 0.0.1 entrypoint: convert - -resize 512x512 - path: /resize512 FROM debian RUN apt-get update RUN apt-get install -y imagemagick ENTRYPOINT ["convert", "-", "-resize", "512x512", "-"] Dockerfilefunc.yml
  17. 17. #BaselOne18 What is the FDK?  A Functions Development Kit, is a set of libraries in Fn for:  Simplifying function development  Avoid dealing with STDIN, STOUT directly  Reduce complexity  Support for: Java, Go, Python, Ruby, Node, etc.
  18. 18. #BaselOne18 DEMO and walkthrough
  19. 19. #BaselOne18 The Fn CLI > fn start > fn init --runtime java --trigger http jfn > fn deploy --app myapp --local > fn list app && fn list t myapp > echo –n «Bob» | fn invoke myapp jfn > curl –d «Bob» http://...:8080/t/myapp/jfn-trigger
  20. 20. #BaselOne18 The Fn App-structure  (optional) root-folder  app.yaml  defines the app name  function-folder  func.yaml (name, trigger, container, fdk definitions)  source
  21. 21. #BaselOne18 Fn Apps & Triggers (API v2)  Apps  The way to logically group FN Functions and triggers  Triggers  Pointers /endpoints to the functions  Multiple triggers to the same function
  22. 22. #BaselOne18 The Fn func.yaml name: helloworld cmd: ....fn.HelloFunction::handleRequest format: http triggers: - name: helloworld-trigger type: http source: /helloworld-trigger public class HelloFunction { public String handleRequest(String input) { String name = input; return "Hello, " + name + "!"; } } curl –d «Bob» http://...:8080/t/myapp/helloworld-trigger func.yaml HelloFunction.java name: myapp app.yaml
  23. 23. #BaselOne18 Fn deployment details 1. Build container + update version Code MyFunc:0.0.3 1 MyFunc:0.0.3 2 MyFunc:0.0.3 Fn Service myfunc  /t/myapp/myfunc 3 2. Push container to registry 3. Create/update function route
  24. 24. #BaselOne18 Configure Fn functions Three ways to set configuration variables (Available as environmental variables) 1.Application level configuration > fn config app myapp KEY value 1.Configuration from func.yaml 2.Function level configuration > fn config function myapp jfn KEY value
  25. 25. #BaselOne18 Fn Java-FDK Unit-Testing The Fn Java (and other) FDK(s) provides an API for testing @Rule public final FnTestingRule testing = FnTestingRule.createDefault(); @Test public void shouldReturnGreeting() { testing.givenEvent().enqueue(); testing.thenRun(HelloFunction.class, "handleRequest"); FnResult result = testing.getOnlyResult(); assertEquals("Hello, world!", result.getBodyAsString()); }
  26. 26. #BaselOne18 Fn Java-FDK input / output mapping  The Fn Java FDK supports JSON input & output through Jackson by default.  Custom mapping of incoming inputStream
  27. 27. #BaselOne18 Fn asynchronous functions  Async functions are queued up  Run at some point in the future  Great for expensive / bulk operations  There is no immediate response  Instead a JSON returns with the call_id  Check the status by invoking: > fn get call myapp call_id
  28. 28. #BaselOne18 https://github.com/fnproject/tutorials/blob/master/grafana/README.md Fn metrics using Prometheus & Grafana  Fn server exposes i.e. performance & resource consumption  OpenTracing API
  29. 29. #BaselOne18 Fn UI
  30. 30. #BaselOne18 FN FLOW introduction
  31. 31. #BaselOne18 Fn Flow • Composing functions
  32. 32. #BaselOne18 Fn Flow  Fn Flow lets you build:  Long-running, reliable & scalable functions  Supports complex parallel processes  Orchestrates computation beyond the life-cycle of functions  Provides monitoring and tracing
  33. 33. #BaselOne18 Fn Flow API • Lot of concepts taken from Java 8 CompletableFuture API Flow fl = Flows.currentFlow(); return fl.supply(() -> "some value") .thenApply(i -> "Your value is: " + i).get(); • Invoking other functions asynchronously • Handling errors fl.supply(() -> throw new Exception("Error")) .exceptionallyCompose(err -> fl.invokeFunction("./recover",...); fl.invokeFunction("myapp/myfn", HttpMethod.GET);
  34. 34. #BaselOne18 Fn Flow UI
  35. 35. #BaselOne18 Fn Flow Demo https://medium.com/fnproject/serverless-sagas-with-fn-flow-d8199b608b12
  36. 36. #BaselOne18 Fn Flow Demo Flow f = Flows.currentFlow(); FlowFuture<BookingRes> flightFuture = f.invokeFunction("./flight/book", input.flight, BookingRes.class); FlowFuture<BookingRes> hotelFuture = f.invokeFunction("./hotel/book", input.hotel, BookingRes.class); FlowFuture<BookingRes> carFuture = f.invokeFunction("./car/book", input.carRental, BookingRes.class); flightFuture.thenCompose( (flightRes) -> hotelFuture.thenCompose( (hotelRes) -> carFuture.whenComplete( (carRes, e) -> EmailReq.sendSuccessMail(flightRes, hotelRes, carRes) ) .exceptionallyCompose( (e) -> cancel("./car/cancel", input.carRental, e) ) ) .exceptionallyCompose( (e) -> cancel("./hotel/cancel", input.hotel, e) ) ) .exceptionallyCompose( (e) -> cancel("./flight/cancel", input.flight, e) );
  37. 37. #BaselOne18 FN & KUBERNETES
  38. 38. #BaselOne18 Fn architecture Fn LoadbalancerFn Loadbalancer Fn ServerFn Server Fn ServerFn Server Fn ServerFn Server Object store (logs, etc.) Object store (logs, etc.) Database (metadata, routes) Database (metadata, routes) MQ (for async) MQ (for async)
  39. 39. #BaselOne18 Fn + Kubernetes Fn Load Balancer (LB) needed for scale out - LB is aware of active (hot) containers Fn Servers are the execution run-time - Typically deployed as DeamonSet Fn LoadbalancerFn Loadbalancer ...... Fn ServerFn Server ......
  40. 40. #BaselOne18 Fn + Kubernetes  Fn-helm provides a Helm Chart 1. git clone https://github.com/fnproject/fn-helm.git && cd fn-helm 2. helm dep build fn 3. helm install --name my-release fn  What you get is:  Fn  Fn UI  Flow  Flow UI
  41. 41. #BaselOne18 CONCLUSION Fn + Serverless + FaaS
  42. 42. #BaselOne18 From monolith to function? monolithmonolith microservicemicroservice microservicemicroservice microservicemicroservice functionfunction functionfunction functionfunction functionfunction functionfunction Vs. time & complexity
  43. 43. #BaselOne18 From monolith to function? Core business (durable) apps (volatile) mm mm mm mm mmff ff ff ff ff ff ff ff ff ff B2B – app(s) B2B – app(s) B2C – app(s) B2C – app(s)
  44. 44. #BaselOne18 Core business Core business From monolith to function? apps (volatile) ff ff ff ff ff ff ff ff ff ff B2B – app(s) B2B – app(s) B2C – app(s) B2C – app(s) (monolith)
  45. 45. #BaselOne18 Core business Core business From monolith to function? «anti-corruption layer» mm mm mm mm mmff ff ff ff ff ff ff ff ff ff (new) core UI (new) core UI (monolith)
  46. 46. #BaselOne18 From monolith to function? Core business (durable) «anti-corruption layer» mm mm mm mm mm ff ff ff ff ff ff ff ff (new) core UI (new) core UI
  47. 47. #BaselOne18 Conclusion „serverless“ • Good supplement to complex core systems – “anti-corruption/pollution layer” – gateway/proxy, backends for frontends – B2B & B2C applications • API “facade” – hide migration details / API changes – decouple frontend / backend modernization
  48. 48. #BaselOne18 Conclusion „serverless“ • Scalable & convenient solution on-prem. / cloud – quick ramp up time for developers – quick ramp up time for ops. in cloud & container – no permanent resource usage – managed environment – pay per use
  49. 49. #BaselOne18 Conclusion Fn project • Pro – quick ramp up for devs. / work locally – few dependencies to FDK / small vendor lock-in – Docker native / integrate existing (OSS) tools – multi-cloud / on-premise – CloudNative event support – integration with the “Serverless Framework” – strong focus on business
  50. 50. #BaselOne18 Conclusion Fn project • Contra – still in development – newly published API v2 (after announcing v1 last year) – still small distribution
  51. 51. Thank youThank you •Andy MoncsekAndy Moncsek •Principal ConsultantPrincipal Consultant •Andy.Moncsek@trivadis.comAndy.Moncsek@trivadis.com •Twitter: @AndyAHCPTwitter: @AndyAHCP 19.10.18 51 Going serverless with Fn project, Fn Flow and Kubernetes
  52. 52. Links • https://hackernoon.com/part-ii-fn-load-balancer-585babd90456 • https://medium.com/@denismakogon/advanced-programming-techniques-with-the- fn-platform-cf70b660bcb9 • https://medium.com/fnproject/useful-tips-for-a-new-fdk-development-78f931477c49 • https://github.com/fnproject/tutorials/tree/master/FlowSaga • https://medium.com/fnproject/getting-started-with-fn-project-65c334b0a63f • https://medium.com/fnproject/setting-functions-free-15d063be72bf • https://banzaicloud.com/blog/fn/ • https://static.rainfocus.com/oracle/oraclecode18/sess/1517600039041001s1gC/PF/ Oracle%20Code%20NY%202018%20Presentation%20-%20Fn %20Project_1521059554862001Da6n.pdf Bezeichnung Präsentation 5219.10.18

    Be the first to comment

    Login to see the comments

  • SuhasRao4

    Oct. 25, 2018
  • DanErez

    Jul. 30, 2020

Fn Project is a container native, easy to use serverless platform developed by Oracle. With Fn flow, the platform provides a powerful flow engine to build long-running, reliable and scalable functions and to orchestrate processes between functions. Deployed on Kubernetes you get a high scaling solution to build serverless applications capable of handling even complex business scenarios. In this talk I will give a short introduction to Serverless, FaaS and Fn project, you will see how to deploy it in Kunernetes and how to integrate it with your existing applications.

Views

Total views

335

On Slideshare

0

From embeds

0

Number of embeds

2

Actions

Downloads

4

Shares

0

Comments

0

Likes

2

×