Build serverless application on top of Kubernetes #sdmel19

Build serverless application on top of Kubernetes #sdmel19

ServerlessDays Melbourne 2019 @Melbourne Museum by toshi0607 #sdmel19

https://www.serverlessdays.me/speakers/toshinori-sugita/

YouTube is here!
https://youtu.be/K7RYOPYiitA

C000f292a92b894afabbb352e8709667?s=128

Toshinori Sugita

August 29, 2019
Tweet

Transcript

  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.
 ※https://kubernetes.io/
  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
 ※https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
  6. How do we build a service with K8s?
 • write

    code
 • 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

    workloads
 ※https://github.com/knative
  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
 ※https://github.com/knative/docs
  15. Knative stack
 ※https://github.com/knative/docs/tree/master/docs Kubernetes
 Istio, Gloo or Ambassador
 Serving
 Build


    Eventing
 Platform
 Gateway
 Primitives

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

    
 Serving
 Build
 Eventing
 Platform
 Gateway
 Primitives
 GitLab Serverless
 Your Own!
 Pivotal Function Service
 Cloud Run
 SAP Kyma
 Knative Lambda Runtimes
 Products

  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
 ※https://cloudevents.io/

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

    runtime
 ◦ (+) 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.
 ※https://cloud.google.com/run/
  22. Serverless options in GCP
 ※https://cloud.google.com/serverless-options/

  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
 ServerlessDays

    Melbourne 2019 @Melbourne Museum by toshi0607