Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Spring Cloud Function & Project riff #jsug

3.743 Aufrufe

Veröffentlicht am

JSUG 2018-02

Veröffentlicht in: Technologie
  • Als Erste(r) kommentieren

Spring Cloud Function & Project riff #jsug

  1. 1. Spring Cloud Function & Project riff Japan Spring User Group 2018-02-06 Toshiaki Maki (@making) / Pivotal
  2. 2. • Keynote day2 • https://www.youtube.com/watch? v=mlRSp9Z3zwY • Serverless Spring • https://www.youtube.com/watch? v=mPOl3024R4s Featured Sessions
  3. 3. CONTAINERS EVENT-DRIVEN FUNCTIONS DATA SERVICES MICROSERVICES Batches MONOLITHIC APPLICATIONS Companies have many ways to package and run their workloads in the cloud
  4. 4. Their goal: pick the right runtime for each workload CONTAINERS EVENT-DRIVEN FUNCTIONS DATA SERVICESMICROSERVICES Batches MONOLITHIC APPLICATIONS IaaS Container Orchestrator (CaaS) Application
 Platform (PaaS) Serverless
 Functions (FaaS)
  5. 5. Why Serverless? 8 1. Narrowly-scoped units of code, and the simplicity of built-in event integration, contribute to software development efficiencies. 2. Functions which don't consume resources when idle can provide significant resource efficiencies. 3. Applying serverless to distributed computing brings operational efficiencies based on automated event-based scheduling and self- scaling.
  6. 6. Who is offering FaaS? Hosted • AWS Lambda • Azure Functions • Google Cloud Functions On-Prem / OSS • riff (https://github.com/projectriff ) • Oracle fn • OpenWhisk • Fission • Kubeless • OpenFaaS
  7. 7. • Focus on the implementation of business logic via functions • Decouple the business logic from any specific runtime (HTTP, Message) • Support a uniform programming model across FaaS providers • Run standalone (locally or in a PaaS) • Enable Spring Boot features on FaaS providers Spring Cloud Function
  8. 8. Spring Cloud Function • FaaS Portable • Run in Spring Boot • REST, Tasks, or Streams https://github.com/spring-cloud/spring-cloud-function
  9. 9. HTTP Message Functions Spring Cloud Function Web Spring Cloud Function Message Spring Boot
  10. 10. HTTP Message Functions Spring Cloud Function Adapter Faas Provider
  11. 11. HTTP Message Functions Spring Cloud Function Adapter Faas Provider Currently • AWS lambda • Azure Function • Apache OpenWhisk are supported
  12. 12. Java Util Function public interface Function<T, R> { R apply(T t); } public interface Consumer<T> { void accept(T t); } public interface Supplier<T> { T get(); }
  13. 13. Write a function package functions; import java.util.function.Function; public class Greeter implements Function<String, String> { public String apply(String name) { return "Hello " + name; } }
  14. 14. Spring Cloud Function (Web) <dependency> <groupId>org.springframework.cloud<groupId> <artifactId>spring-cloud-function-web</artifactId> <version>1.0.0.M3</version> </dependency>
  15. 15. Spring Cloud Function (Message) <dependency> <groupId>org.springframework.cloud<groupId> <artifactId>spring-cloud-function-message</ artifactId> <version>1.0.0.M3</version> </dependency>
  16. 16. Spring Cloud Function @SpringBootApplication public class App { @Bean public Greeter greeter() { return new Greeter(); } public static void main(String[] args) { SpringApplication.run(App.class, args); } }
  17. 17. Spring Cloud Function @SpringBootApplication @FunctionScan public class App { public static void main(String[] args) { SpringApplication.run(App.class, args); } }
  18. 18. Spring Cloud Function (Web) $ curl localhost:8080/greeter -w 'n' -H "Content-Type: text/plain" -d "JSUG" Hello JSUG
  19. 19. DEMO https://github.com/making/demo-function
  20. 20. Project riff https://projectriff.io/
  21. 21. riff is for functions
  22. 22. Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ what is riff? 24 riff provides developers with a service for executing Functions in response to Events. Features ★ event streaming ★ polyglot ★ Kubernetes-native Events f(x) f(x) f(x) Functions f(x) riff
  23. 23. Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 25 🚧 Immediate Instant-on Consistent Immutable Containers Efficient Scale to Zero Choice of Compromises: • Launch Function containers on demand
 => Slow start • Inject Function code into running containers
 => Breaks container immutability • Keep Function containers running
 => Pay for idle resources ICE
 Want serverless?... pick 2
  24. 24. Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ functions are packaged as containers 26 Function Invoker Function Code Container Base Image Function Layer Container Registry
  25. 25. Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ functions are packaged as containers 26 Function Invoker Function Code Container Base Image Function Layer Container Registry Currently • Java • JavaScript • Bash • Python are supported
  26. 26. Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ sidecars connect functions with event brokers 27 Function Pod Function ContainerSidecar Container Event
 Broker broker-specific API binder dispatcher invoker function HTTP gRPC stdio pipes
  27. 27. Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ sidecars connect functions with event brokers 27 Function Pod Function ContainerSidecar Container Event
 Broker broker-specific API binder dispatcher invoker function HTTP gRPC stdio pipes + maybe rsocket?
  28. 28. Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 28 functions and topics are Kubernetes resources Function Controller Function YAML - name - input / output topics - artifact / params Topic YAML - name - params KafkaHttp Gateway Topic Controller Sc Fn Pod Sc Fn Pod Sc Fn Pod k8s API
  29. 29. Unless otherwise indicated, these slides are © 2013-2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ functions scale with events riff function controller ★ interacts with K8s API ★ scales functions 0-1 and 1-N ★ monitors event-lag in Kafka 29 Function Controller Event Broker f(x) f(x) f(x) k8s API
  30. 30. kubectl -n kube-system create serviceaccount tiller kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller helm init --service-account=tiller helm repo add riffrepo https://riff-charts.storage.googleapis.com helm repo update Set up helm Installing riff via helm
  31. 31. helm install riffrepo/riff --name demo --version 0.0.3-rbac --set httpGateway.service.type=NodePort Installing riff via helm Set up riff
  32. 32. DEMO https://github.com/making/demo-riff

×