Serverless is one of the hottest design patterns in the cloud today, i’ll cover how the Serverless paradigms are changing the way we develop applications and the cloud infrastructures and how to implement Serveless-kind workloads with Kubernetes.
We’ll go through the latest Kubernetes-based serverless technologies, covering the most important aspects including pricing, scalability, observability and best practices
stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo Mainardi
1. The path to a
Serverless-native era with
Kubernetes
2. Who i am
Paolo Mainardi
@paolomainardi - https://www.paolomainardi.com
➔
➔ CTO of Sparkfabrik -
https://www.sparkfabrik.com/en/
➔ CKA(D) certified, GCP Cloud Architect
➔ We are hiring :)
3. The session
● What is the hype cycle
● Serverless concepts (FaaS, BaaS, *aaS)
● Serverless on Kubernetes
8. “Serverless computing refers to the concept of building and
running applications that do not require server management”
CNCF Serverless Whitepaper v1.0 - https://github.com/cncf/wg-serverless/tree/master/whitepapers/serverless-overview
9. 1. Functions-as-a-Service (FaaS) which typically provides event-driven computing. Developers
run and manage application code with functions that are triggered by events or HTTP
requests. Developers deploy small units of code to the FaaS, which are executed as needed as
discrete actions, scaling without the need to manage servers or any other underlying
infrastructure.
2. Backend-as-a-Service (BaaS) which are third-party API-based services that replace core
subsets of functionality in an application. Because those APIs are provided as a service that
auto-scales and operates transparently, this appears to the developer to be serverless.
Serverless computing platform
14. Use case - Translation service
FaaS - Translation service
Business requirement
Translate text files from Italian to German, both on-demand and batch
uploads.
Non-functional requirements:
● Scale up on demand
● Highly available >= 99.5%
● Scale down to zero
● Pay per use
15. Use case - Translation service
FaaS - Translation service
Architecture overview
● NodeJS
● Google Cloud Platform
○ Cloud services
○ Translate API
18. FaaS - Cloud architecture #1
Non-functional requirements:
● Scale up on demand
● Highly available >= 99.5%
● Scale down to zero
● Pay as you go
19. Non-functional requirements:
● Scale up on demand ❌
● Highly available >= 99.5% ❌
● Scale down to zero ❌
● Pay as you go ❌
FaaS - Cloud architecture #1
Service Instances Cost per month
Compute engine
(n1-standard-1)
1 30$
HTTP(s) load
balancer
1 18$
Fixed costs
TOTAL: 48$
20. FaaS - Cloud architecture #2
Non-functional requirements:
● Scale up on demand ✅
● Highly available >= 99.5% ❌
● Scale down to zero ❌
● Pay as you go ❌
Service Instances Cost per month
Compute engine
(n1-standard-1)
1 30$
HTTP(s) load
balancer
1 18$
Fixed costs
TOTAL: 48$
21. FaaS - Cloud architecture #3
Non-functional requirements:
● Scale up on demand ✅
● Highly available >= 99.5% ✅
● Scale down to zero ❌
● Pay as you go ❌
Service Instances Cost per month
Compute engine
(n1-standard-1)
1 90$
HTTP(s) load
balancer
1 18$
Fixed costs
TOTAL: 108$
22. FaaS - Functions as a service
TRADITIONAL
SERVERLESShttps://cloud.google.com/functions/docs/writing
Serverless refactoring
23. FaaS - Serverless Cloud architecture
Non-functional requirements:
● Scale up on demand ✅
● Highly available >= 99.5% ✅
● Scale down to zero ✅
● Pay as you go ✅
Service Instances Cost per month
- - -
Fixed costs
TOTAL: 0$
25. Functions on public cloud
The state of FaaS on public cloud
● Limited language runtimes (NodeJS, Python, Java, C#)
● Vendor-proprietary mechanisms to package and deploy the functions
26. ● Locked-in language runtime
● Proprietary Event format
●
The state of FaaS on public cloud
FaaS on public cloud
38. What is Kubernetes
What is Kubernetes
https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/
Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services,
that facilitates both declarative configuration and automation.
The name Kubernetes originates from Greek, meaning helmsman or pilot. Google open-sourced the Kubernetes
project in 2014. Kubernetes combines over 15 years of Google’s experience running production workloads at scale
with best-of-breed ideas and practices from the community.
40. What is Kubernetes - Kubelet
Kubelet
An agent that runs on each node in the cluster.
It makes sure that containers are running in a Pod
41. What is Kubernetes - Pods
Pods
A Pod is a group of one or more containers with
shared storage/network, and a specification for how
to run the containers
45. Serverless & Kubernetes
Have to do Want to do
Write code
Build docker image
Push docker image to registry
Developer experience on Kubernetes
46. Serverless & Kubernetes
Have to do Want to do
Write code
Build docker image
Push docker image to registry
Write yaml manifests
Developer experience on Kubernetes
47. Serverless & Kubernetes
Have to do Want to do
Write code
Build docker image
Push docker image to registry
Write yaml manifests
kubectl apply -f myapp/
Developer experience on Kubernetes
48. Serverless & Kubernetes
Have to do Want to do
Write code Write code
Build docker image
Push docker image to registry
Write yaml manifests
kubectl apply -f myapp/
Developer experience on Kubernetes
49. Serverless & Kubernetes
Have to do Want to do
Write code Write code
Build docker image Ship it
Push docker image to registry
Write yaml manifests
kubectl apply -f myapp/
Developer experience on Kubernetes
50. Serverless & Kubernetes
Developing on Kubernetes is not easy
1. It’s not the right abstractions for end-developer
experience (eg: deployment, service, ingress, hpa,
monitoring)
2. But it’s a great platform to build a PaaS on top of
it: Primitives, Extensibility
52. ● Something to wake-up workloads on request
● Something to scale-up and scale back to zero
● Something to turn the source code into a container
● An eventing system with configurable sources and subscribers
Serverless on Kubernetes to-do list:
53. Knative
Kubernetes-based platform to build deploy and manage modern
serverless workloads.
Knative offers features like scale-to-zero, autoscaling and eventing
framework
https://knative.dev
KNATIVE
56. Knative
Knative serving
1. Scale-up and scale back to zero
2. Fine-grained traffic routing
3. Automatic metrics and telemetry
4. Point-in-time snapshot of code and
configurations (revisions)
61. Knative
Knative build
“Deprecating Knative Build would resolve this confusion as it would make it clear that the
"building the service(s) image" part is not Knative's responsability and user can use whatever
tools is capable of doing that — preferably Tekton Pipelines 👼.”
62. Knative
Tekton
1. The Tekton project provides Kubernetes-style resources for
declaring CI/CD-style pipelines
2. Builds are ran completely within Kubernetes (eg: Kaniko, Buildkit)
and using standard formats like buildpacks
3. Openly-governed under the Continuous Delivery Foundation (CDF)
63. Knative
● As a developer: Use it directly to deploy your stuff in a more
streamlined way than raw Kubernetes.
What you can do with Knative
64. Knative
● As a developer: Use it directly to deploy your stuff in a more
streamlined way than raw Kubernetes.
● As an operator: Put a level of abstractions between Kubernetes
and your devs; Keep the costs under control thanks to
auto-scaling features.
What you can do with Knative
65. Knative
● As a developer: Use it directly to deploy your stuff in a more
streamlined way than raw Kubernetes.
● As an operator: Put a level of abstractions between Kubernetes
and your devs; Keep the costs under control thanks to
auto-scaling features.
● As a platform architect: Build your own PaaS/FaaS platform,
relying on the Knative primitives.
What you can do with Knative
67. Knative - Google Cloud Run
Google CloudRun
1. Fully GCP managed Serverless
platform based on Knative apis
2. Event-driven architecture (HTTP +
Pub/Sub)
3. Cloud Run + Cloud run for Anthos
4. A sort of managed Knative + Istio
Credits: https://twitter.com/ahmetb/status/1116041166359654400
68. Knative - Google Cloud Run
Google CloudRun
1. Fully GCP managed Serverless
platform based on Knative apis
2. Event-driven architecture (HTTP +
Pub/Sub)
3. Cloud Run + Cloud run for Anthos
4. A sort of managed Knative + Istio
Credits: https://ahmet.im/blog/cloud-run-is-a-knative/
69. Knative - Openshift serverless
Openshift Serverless
1. GA product since 30rd of April
2. Based on Knative Serving + Eventing + Tekton pipeline
3. Fully integrated with the Openshift ecosystem.
Pivotal Riff
1. Deep Kubernetes integration using CRDs
2. Pluggable application runtimes [Core, Knative...]
3. A custom builder based on buildpacks.io (source to container)
4. A custom cli tool “riff” to manage the entire lifecycle
71. Keda
Keda is an open-source CNCF sandbox project
from Microsoft and Redhat
KEDA provides a lightweight auto-scaling infrastructure
that allows to autoscale applications based on custom criteria
KEDA - Kubernetes Event Driven Autoscaling
https://keda.sh
76. Kubernetes-native serverless platforms
➔ OSS platforms
➔ Flexible language runtimes
➔ Custom CLIs
➔ Written in GO (OpenWhisk in
Scala)
➔ Backed by big vendors (Oracle,
IBM, Vmware)
Kubernetes fully fledged serverless platforms
78. Virtual Kubelet
Virtual Kubelet
Virtual Kubelet is an open-source Kubernetes kubelet
implementation that masquerades as a kubelet.
This allows Kubernetes nodes to be backed by Virtual Kubelet
providers such as serverless cloud container platforms
https://virtual-kubelet.io
85. ● Flexible language runtimes based on containers
● Run on multi/hybrid cloud and on your laptop
Serverless & Kubernetes
Serverless on Kubernetes:
86. Serverless & Kubernetes
Serverless on Kubernetes:
● Flexible language runtimes based on containers
● Run on multi/hybrid cloud and on your laptop
● Mix and match stateless and stateful workloads
87. Serverless & Kubernetes
Serverless on Kubernetes:
● Flexible language runtimes based on containers
● Run on multi/hybrid cloud and on your laptop
● Mix and match stateless and stateful workloads
● Extensibility and a better development experience
89. In the cloud platforms, Serverless & k8s will essentially converge and
we’ll deploy just by asking:
“Kubernetes, just run my code”
Alexis Richardson, Founder and CEO, Weaveworks