This post originally appeared on LinkedIn and has been updated since.
It’s hard to not be overwhelmed with the hype around serverless; the term seems to be constantly redefined to mean almost anything. I wanted to look at how easy it would be to do a serverless web app (which is to say: an app that responds to HTTP requests and does some work and when there isn’t work to be done - scales down to zero cost).
I previously wrote about using AWS Lambda (best known for being Function as a Service) after a Friday afternoon exploring it. The experience was a little frustrating at first because of the components needed (I won’t flesh out the details again, but please note the linked blog has a video with some strong, but amusing language). The end result was great of course, which is what counts.
My goal, similar to my AWS Lambda experiment, was to see how quickly I could get to “Hello World” using the off-the-shelf tools and examples (i.e. nothing exotic). Being a tiny bit familiar with GKE (Google’s Kubernetes engine thing) I thought it made sense.
The steps I took were pretty simple:
- Followed the step-by-step guide for setting up Knative and a cluster (I expect one day that will be out of the box)
- Made sure the Node.js sample app, worked (I added the IP address to my /etc/hosts so I could use a browser to test out without DNS shenanigans)
- Checked to see if the Spring boot sample worked with heavier things like the JVM
- Ensured the pods would scale down to zero by running “kubectl get pods” to check that after a minute or so there was nothing running. This last step is not really needed, but I wanted to satisfy myself. Running an app (via curl, or visiting in a web browser) would wake it up again of course!
What this left me with was a couple of trivial web apps that scale to zero pods when not in use and wake-up when needed. This, I guess, is the heart of serverless. Of course these specific examples assume the developer knows a little about containers, so this isn’t Function as a Service, although that is coming (check out Project Riff). However to most developers, this would be very, very comfortable and familiar. AWS Lambda recently included support for things like express.js on top of Lambda+API Gateway, which to me is a strong signal there is a demand for building apps with familiar frameworks, but deploying them via serverless patterns.
Note I didn’t mention Istio or any of that stuff as part of this; sure it is in there doing magic, but I don’t really care about that. Service mesh is important, but it isn’t the point of serverless. I think this is the future of how web apps should be deployed, unless they have a good reason to be running all the time due to workload. Knative-serve for Kubernetes should be the way web apps (at least) are run. This is just software now.
I found this was far quicker for me than working out Lambda (in terms of getting to Hello World), and included setting up a cluster from scratch and installing a bunch of stuff (Kubernetes does make it easy to “install” things, it really does feel a bit like an operating system). I would expect in the near future for cloud providers to bake this in, saving even more steps.
The Knative project as launched really has two main components:
- Knative-serve: Which as outlined above, I tried.
- Knative-build: Its job is to take source and make containers and Knative deployments out of it. This is also required for the Function as a Service experience to be similar to things like AWS Lambda.
On the Knative-build side, this was largely the source of the Tekton project (now part of the Continuous Delivery Foundation). There is a lot of work happening that is building great stuff on top of Knative-build/Tekton, and this is I think where a lot of future innovation will happen. I would recommend tracking Jenkins X to see what they do with Tekton as I know they are using it.
Knative is certainly a really important project to keep an eye on if you are in the Kubernetes world and curious about serverless ideas. Of course AWS Lambda (and the AWS suite of serverless.. uh… services) has a huge edge in scale and ability to put functions on all sorts of events that will ensure it has enduring popularity.
There are many examples of Knative Serving sample applications, including a great one showing auto scaling in action. You could almost think of Knative-serve as auto scale done right, and right out of the box. I also recommend checking out pragmatic walkthroughs of Knative by my buddy Dr. Nic.