to build the application and the [TriggerMesh CLI](https://github.com/triggermesh/tm) to simplify the
to build the application and the [TriggerMesh CLI](https://github.com/triggermesh/tm) to simplify the
deployment of knative services and functions.
deployment of knative services and functions.
1.**`serverless.yml`** (for [functions only](#deploying-functions)): When using serverless to deploy functions, the `serverless.yaml` file
1.**`serverless.yaml`** (for [functions only](#deploying-functions)): When using serverless to deploy functions, the `serverless.yaml` file
will contain the information for all the functions being hosted in the repository as well as a reference to the
will contain the information for all the functions being hosted in the repository as well as a reference to the
runtime being used.
runtime being used.
1.**`Dockerfile`** (for [applications only](#deploying-serverless-applications): Knative requires a `Dockerfile` in order to build your application. It should be included
1.**`Dockerfile`** (for [applications only](#deploying-serverless-applications): Knative requires a `Dockerfile` in order to build your application. It should be included
...
@@ -79,7 +79,7 @@ Using functions is useful for initiating, responding, or triggering independent
...
@@ -79,7 +79,7 @@ Using functions is useful for initiating, responding, or triggering independent
events without needing to maintain a complex unified infrastructure. This allows
events without needing to maintain a complex unified infrastructure. This allows
you to focus on a single task that can be executed/scaled automatically and independently.
you to focus on a single task that can be executed/scaled automatically and independently.
At launch, the following runtimes are offered:
At launch, the following [runtimes](https://gitlab.com/triggermesh/runtimes) are offered:
- node.js
- node.js
- kaniko
- kaniko
...
@@ -123,7 +123,7 @@ In order to deploy functions to your Knative instance, the following files must
...
@@ -123,7 +123,7 @@ In order to deploy functions to your Knative instance, the following files must
@@ -133,35 +133,36 @@ In order to deploy functions to your Knative instance, the following files must
...
@@ -133,35 +133,36 @@ In order to deploy functions to your Knative instance, the following files must
FUNCTION:echo
FUNCTION:echo
```
```
The `serverless.yaml` file contains three section with distinct parameters:
The `serverless.yaml` file contains three sections with distinct parameters:
### `service`
### `service`
| Parameter | Description |
| Parameter | Description |
|-----------|-------------|
|-----------|-------------|
| `service` | Name for the Knative service which will serve the function |
| `service` | Name for the Knative service which will serve the function. |
| `description` | A short description of the `service` |
| `description` | A short description of the `service`. |
### `provider`
### `provider`
| Parameter | Description |
| Parameter | Description |
|-----------|-------------|
|-----------|-------------|
| `name` | Indicates which provider is used to execute `serverless.yaml` file. In this case the TriggerMesh `tm` CLI |
| `name` | Indicates which provider is used to execute the `serverless.yaml` file. In this case, the TriggerMesh `tm` CLI. |
| `registry-secret` | Indicates which registry will be used to store docker images |
| `registry-secret` | Indicates which registry will be used to store docker images. The sample function is using the `GitLab registry`, however, you can use other popular registries such as `Docker Hub`, `Google Container Registry`, or `Amazon EC2 Container Registry`. |
| `environment` | Includes the environment variables to be passed as part of function execution for **all** functions in the file, where `FOO` is the variable name and `BAR` are he variable contents. You may replace this with you own variables |
| `environment` | Includes the environment variables to be passed as part of function execution for **all** functions in the file, where `FOO` is the variable name and `BAR` are he variable contents. You may replace this with you own variables. |
### `functions`
### `functions`
In the provided sample, line no. 11 contains the function name (in this sample, `"echo"`). The subsequent lines contain the function attributes:
In the `serverless.yaml` example above, the function name is `echo` and the subsequent lines contain the function attributes.
| Parameter | Description |
| Parameter | Description |
|-----------|-------------|
|-----------|-------------|
| `handler` | Reference to function file name (in the sample both the function name and the handler are the same) |
| `handler` | The function's file name. In the example above, both the function name and the handler are the same. |
| `runtime` | Reference to the runtime to be used to execute the function |
| `runtime` | The runtime to be used to execute the function. |
| `description` | A short description of the function |
| `description` | A short description of the function. |
| `buildargs` | Pointer to the function file in the repo (in the sample the function is located in the `echo` directory) |
| `buildargs` | Pointer to the function file in the repo. In the sample the function is located in the `echo` directory. |
| `environment` | Sets an environment variable for the specific function only |
| `environment` | Sets an environment variable for the specific function only. |
After the `gitlab-ci.yml` template has been added and the `serverless.yaml` file has been
After the `gitlab-ci.yml` template has been added and the `serverless.yaml` file has been
created, each function must be defined as a single file in your repository. Committing a
created, each function must be defined as a single file in your repository. Committing a
...
@@ -183,7 +184,7 @@ The function details can be retrieved directly from Knative on the cluster:
...
@@ -183,7 +184,7 @@ The function details can be retrieved directly from Knative on the cluster:
kubectl -n"$KUBE_NAMESPACE" get services.serving.knative.dev
kubectl -n"$KUBE_NAMESPACE" get services.serving.knative.dev
```
```
The sample function can now be triggered from any http client using a simple `POST` call
The sample function can now be triggered from any HTTP client using a simple `POST` call.