Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Build serverless application on top of Kubernetes #sdmel19

Build serverless application on top of Kubernetes #sdmel19

ServerlessDays Melbourne 2019 @Melbourne Museum by toshi0607 #sdmel19


YouTube is here!


Toshinori Sugita

August 29, 2019

More Decks by Toshinori Sugita

Other Decks in Technology


  1. Build serverless application on top of Kubernetes
 ServerlessDays Melbourne 2019

    @Melbourne Museum by toshi0607

  2. About Me
 • Toshinori Sugita
 ◦ toshi0607
 • Tokyo, Japan

    • Software Engineer @Merpay, Mercari
 ◦ developing payment service with Go, gPRC and GKE
 • Active in Serveless Community (JP)
 ◦ Serverless Meetup Tokyo, Serverless Days Tokyo
 • OSS Contributor
 ◦ Serverless Framework, aws-lambda-go/dotnet, Knative, KEDA
 • Author
 ◦ How to deal with Knative (ja), Learning AWS Lambda with Go (ja)

  3. What I learned and lost in 3 weeks in Cairns

    • lost my smartphone on the first day
 • how to play beach volleyball
 • blueness of the sky and the sea
 • brownness of TimTam

  4. Kubernetes
 Kubernetes (K8s) is an open-source system for automating deployment,

    scaling, and management of containerized applications.
  5. Concept of Kubernetes
 • apply desired state to your cluster

    defined in declarative manner
 • controllers on K8s watch and keep desired state
 →reduce operational cost by auto recovery in trouble and auto scaling at high load
  6. How do we build a service with K8s?
 • write

 • write Dockerfile
 • build Docker image
 • push image to registry
 • deploy service
 • expose service to internet
 • set up monitoring
 • set up autoscaling
 →We want to focus more on writing code!

  7. Serverless
 ※https://github.com/cncf/wg-serverless/tree/master/whitepapers/serverless-overview Serverless computing refers to the concept of building

    and running applications that do not require server management. It describes a finer-grained deployment model where applications, bundled as one or more functions, are uploaded to a platform and then executed, scaled, and billed in response to the exact demand needed at the moment.

  8. Serverless
 ※https://github.com/cncf/wg-serverless/tree/master/whitepapers/serverless-overview the idea that consumers of serverless computing no

    longer need to spend time and resources on server provisioning, maintenance, updates, scaling, and capacity planning. Instead, all of these tasks and capabilities are handled by a serverless platform and are completely abstracted away from the developers and IT/operations teams. 

  9. Serverless
 ※https://github.com/cncf/wg-serverless/tree/master/whitepapers/serverless-overview As a result...
 • Developers
 ◦ can focus

    on writing their applications’ business logic. 
 • Operations engineers
 ◦ can elevate their focus to more business critical tasks.
 →We want to realize this situation on top of K8s

  10. Serverless
 ※https://github.com/cncf/wg-serverless/tree/master/whitepapers/serverless-overview A serverless computing platform may provide one or

    both of the following:
 • Function as a Service (FaaS)
 • Backend as a Service (BaaS)
 →K8s itself is not FaaS or BaaS. How do we build serverless application on top of K8s?

  11. Knative
 Kubernetes-based platform to build, deploy, and manage modern serverless

  12. Kubernetes and Sserverless
 ※https://github.com/knative/serving/blob/master/docs/spec/motivation.md Knative defines serverless workloads as computing

    workloads that are:
 • Stateless
 • Amenable to the process scale-out model
 • Primarily driven by application level (L7 -- HTTP, for example) request traffic

  13. Kubernetes and Sserverless
 ※https://github.com/knative/serving/blob/master/docs/spec/motivation.md • K8s provides basic primitives like

    Deployment, and Service in support of the model
 →by standardizing on higher-level primitives which perform substantial amounts of automation of common infrastructure, it should be possible to build consistent toolkits that provide a richer experience than updating yaml files with kubectl.

  14. What is Knative?
 • Abstract K8s resources
 ◦ make K8s

    resources simple for developers and operators
 • Building blocks to build your own PaaS/FaaS
 ◦ Serving, Eventing (and Build)
 • Solving mundane but difficult tasks such as:
 ◦ Deploying a container
 ◦ Routing and managing traffic with blue/green deployment
 ◦ Scaling automatically and sizing workloads based on demand
 ◦ Binding running services to eventing ecosystems
 →build platform to focus more on business value for developers and operators
  15. Knative stack
 ※https://github.com/knative/docs/tree/master/docs Kubernetes
 Istio, Gloo or Ambassador


  16. Serverless platform on K8s
 ※https://github.com/knative/docs/tree/master/docs Kubernetes
 Istio, Gloo or Ambassador

 GitLab Serverless
 Your Own!
 Pivotal Function Service
 Cloud Run
 SAP Kyma
 Knative Lambda Runtimes

  17. Build FaaS on top of K8s with Knative
 • develop

    server to pass request to function because deploying artifacts are a container 
 • decouple the server and function and include them into a single Dockerfile
 • make CLI like faas-cli or tm to put K8s manifests and kubectl out of consciousness
 • use cloudevents handler in your function

  18. Difference from other FaaS on top of K8s
 • Knative

    itself is not FaaS/PaaS. It provides the layer between K8s and serverless framework
 • multiple vendors are developing together as OSS
 • using cloudevents for event handling
 →We can avoid vendor lock in and easily migrate to other Knative based FaaS/PaaS

  19. cloudevents

  20. pros/cons of FaaS on K8s with Knative
 • freedom of

 ◦ (+) Can utilize any language, binary, non vendor SDK
 ◦ (−) Must prepare library by yourself
 • standardize packaging format
 ◦ (+) Don’t use different Zip for each FaaS, but Dockerfile
 ◦ (−) Must learn how to write effective Dockerfile
 →More responsibility, but can make them templated in consistent manner

  21. What is Cloud Run?
 Cloud Run is part of Google

    Cloud and it is a managed serverless platform that enables you to run stateless containers invocable via HTTP requests.
  22. Serverless options in GCP

  23. Summary
 • Knative provides a solution to build severless platform

    on top of K8s
 • Cloud Run provides a managed serveless container platform
 • If you don’t operate K8s clusters, you can choose serverless service between CaaS and FaaS
 • Knative and Cloud Run are not fully matured but have a great potential. I hope to make contributions

  24. Reference (Knative)
 • Docs
 ◦ https://github.com/knative/docs
 • Book
 ◦ 『Getting

    Started with Knative』 free!
 ◦ https://content.pivotal.io/ebooks/getting-started-with-knative
 • Tutorial
 ◦ https://github.com/meteatamel/knative-tutorial
 • Slack
 ◦ https://slack.knative.dev
 • Twitter
 ◦ https://mobile.twitter.com/KnativeProject

  25. Thank you!
 Build servreless application on top of Kubernetes

    Melbourne 2019 @Melbourne Museum by toshi0607