Throughout this book, we have looked at continuous integration and continuous deployment for different serverless providers, but with respect to Kubeless (as it is still developing) there is still a lot that needs to be improved. While writing this book, I found that, using the Serverless Framework, we can only set up deployment if our Kubernetes cluster (minikube), Serverless Framework, and Jenkins are set up locally. There is no provision to set up a remote deployment with the Serverless Framework. But as the Serverless Framework and Kubeless mature over time, these features will be added. In the following tutorials, I have created files to set up deployment locally.
If you clone the repository at https://github.com/shzshi/kubeless-continuous-integration.git, then you should be able to use this template to set up continuous integration locally.
However, we can run the files locally on the laptop, provided we have the Serverless Framework installed and configured. Let's look how do this:
$ git clone https://github.com/shzshi/kubeless-continuous-integration.git
$ cd kubeless-continuous-integration
We should see six files and one directory in this folder, but we won't be using Dockerfiles and Jenkinsfiles in this tutorial. They can be used once remote deployment is possible with the Serverless Framework for Kubeless, as shown in the following code:
$ npm install
$ npm test
> kubeless-nodejs@1.0.0 test /Users/shashi/Documents/packt/chapter7/kubeless-continuous-integration
> mocha ./test/*.js
kubelesshello
✓ should return 0 when "Hello Kubeless" is present
1 passing (8ms)
We ran npm install to get the required dependencies for the Serverless Framework and Node.js application and test. Post that we ran the npm test, for which I created a simple unit test to check the sanity of our function before we deployed them to the cluster, as shown in the following code:
$ serverless deploy -v
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Deploying function kubelesshello...
Serverless: Pods status: {"waiting":{"reason":"PodInitializing"}}
Serverless: Pods status: {"waiting":{"reason":"PodInitializing"}}
Serverless: Function kubelesshello successfully deployed
Serverless: Skipping ingress rule generation
So, our Node.js function will be deployed successfully, and we can invoke it locally or through the Kubeless UI and test it. Post-invocation, we should get the output of Hello Kubeless, as shown in the following code:
$ serverless invoke -f kubelesshello -l
Serverless: Calling function: kubelesshello...
--------------------------------------------------------------------
Hello Kubeless