Complete the steps in this guide to install the Serverless Framework open-source CLI and deploy, invoke and remove a sample service on your Knative installation.
There are a few prerequisites you need to install and configure:
- Install Node.js 8.x or later on your local machine
- Install the Serverless Framework open-source CLI version 1.50.0 or later
If you already have these prerequisites setup you can skip ahead to deploy an example Service.
- Follow these installation instructions.
- At the end, you should be able to run
node -vfrom your command line and get a result like this...
$ node -v vx.x.x
- You should also be able to run
npm -vfrom your command line and should see...
$ npm -v x.x.x
- Run this command in your terminal
npm install -g serverless
- After install is complete, you should be able to run
serverless -vfrom your command line and get a result like this...
$ serverless -v x.x.x
Now that you’ve completed your setup, let’s create and deploy a serverless Service.
- Use the Serverless Framework open-source CLI to create a new Service with
# Create a new Serverless service/project $ serverless create --template knative-docker --path my-service
- Install the dependencies
# Change into the newly created directory $ cd my-service $ npm install
Install Knative on your Kubernetes cluster.
Configure your Knative access to work with the Serverless Framework.
Use this command to deploy your service for the first time and after you make changes to your functions or events in
serverless.yml and want to deploy all changes within your service at the same time.
More information in deploy command
Invokes a Function and returns logs.
serverless invoke -f hello
More information in invoke command
If at any point you no longer need your service, you can run the following command to remove the functions and events that were created. This will delete the resources you created.