Serverless appications are regular applications that “scale to zero”. This means when your application isn’t in use - no resources at all will be used. You only pay for what you use. These applications scale up elastically to meet the workload.
Once you have this feature enabled - all new apps you import or quickstarts you use by default will be serverless style (you can override as needed - see below). You don’t have to change the way you build web apps. This is currently in a preview state (but works well), and in future most web apps will work in this fashion (and this will be the default).
Enabling serverless apps
jx create addon gloo
And you are then good to go. Any new projects you create will be created in this serverless style.
If your application was imported recently into Jenkins X but before you installed and enabled Knative Serve you can use jx edit deploy to switch between the default deployment kind (using kubernetes Deployment and Service resources) and the knative kind (using Knative Service resource)
jx edit deploy
This command will modify the knativeDeploy flag in your helm charts/myapp/values.yaml file to enable / disable Knative Serve. Once you have committed that code change and merged to master your application will be released to staging using Knative Serve by the automated CI/CD pipeline in Jenkins X.
Edit your team’s deploy kind
You can edit the default deployment kind for your team which is used when’re you create a QuickStart or import a repository via the jx edit deploy command with the -t argument:
jx edit deploy -t
How it works
We use an open source project called Knative to provide the elastic scaling of your applications and functions.
Knative Serve exposes functions in any programming language over HTTP with elastic scaling from zero to many pods. This lets you build serverless applications which run on any cloud or kubernetes cluster and make an efficient use of resources.
The Jenkins X builld packs create a Knative Serve resource in your helm chart at charts/myapp/templates/ksvc.yaml. This resource is only created if the knativeDeploy flag is true / otherwise the default kubernetes Service & Deployment are created.
Installing Knative Serve
Gloo is much smaller and simpler to install than Istio so in this guide we are going to use that.