|
1 | 1 | # Kubeless Runtime Variants
|
2 | 2 |
|
3 |
| -By default Kubeless has support for runtimes in different states: stable and incubator. You can find the different runtimes available in this repository: |
| 3 | +By default Kubeless has support for runtimes in different states: stable and incubator. You can find the different runtimes available in this repository: |
4 | 4 |
|
5 | 5 | [https://github.com/kubeless/runtimes](https://github.com/kubeless/runtimes).
|
6 | 6 |
|
@@ -55,7 +55,7 @@ $ kubeless function deploy myFunction --runtime nodejs6 \
|
55 | 55 |
|
56 | 56 | **For Webpack Users**
|
57 | 57 |
|
58 |
| -Your webpacked functions will be `require()`-d in so your bundle should work out of the box. However, if your bundle size is approaching 1mb you should take advantage of Kubeless' ability to install dependencies for you instead of bundling them all into your payload. |
| 58 | +Your webpacked functions will be `require()`-d in so your bundle should work out of the box. However, if your bundle size is approaching 1mb you should take advantage of Kubeless' ability to install dependencies for you instead of bundling them all into your payload. |
59 | 59 |
|
60 | 60 | You will need to customize your webpack config to suit your own project, but below is an sample config of how to achieve this in Webpack 4.x:
|
61 | 61 |
|
@@ -123,7 +123,7 @@ For the Node.js runtime we start an [Express](http://expressjs.com) server and w
|
123 | 123 |
|
124 | 124 | There is the [distroless](https://github.com/GoogleContainerTools/distroless) variant of the Node.js 8 runtime.
|
125 | 125 | The distroless Node.js runtime contains only the kubeless function and its runtime dependencies.
|
126 |
| -In particular, this variant does not contain package manager, shells or any other programs which are part of a standard Linux distribution. |
| 126 | +In particular, this variant does not contain package manager, shells or any other programs which are part of a standard Linux distribution. |
127 | 127 |
|
128 | 128 | The same example Node.js function from above can then be deployed:
|
129 | 129 |
|
@@ -204,7 +204,44 @@ func Handler(event functions.Event, context functions.Context) (string, error) {
|
204 | 204 |
|
205 | 205 | #### Description
|
206 | 206 |
|
207 |
| -Go functions require to import the package `github.com/kubeless/kubeless/pkg/functions` that is used to define the input parameters. The desired method should be exported in the package. You can specify dependencies using a `Gopkg.toml` file, dependencies are installed using [`dep`](https://github.com/golang/dep). |
| 207 | +Go functions require to import the package `github.com/kubeless/kubeless/pkg/functions` that is used to define the input parameters. The desired method should be exported in the package. You can specify dependencies using [go modules](https://blog.golang.org/using-go-modules). |
| 208 | + |
| 209 | +#### Go with Dependency Example |
| 210 | + |
| 211 | +This is an example of a function using the `github.com/sirupsen/logrus` dependency. |
| 212 | + |
| 213 | +```go |
| 214 | +// hellowithdeps.go |
| 215 | + |
| 216 | +package kubeless |
| 217 | + |
| 218 | +import ( |
| 219 | + "github.com/kubeless/kubeless/pkg/functions" |
| 220 | + "github.com/sirupsen/logrus" |
| 221 | +) |
| 222 | + |
| 223 | +// Hello sample function with dependencies |
| 224 | +func Hello(event functions.Event, context functions.Context) (string, error) { |
| 225 | + logrus.Info(event.Data) |
| 226 | + return "Hello world!", nil |
| 227 | +} |
| 228 | +``` |
| 229 | + |
| 230 | +```go |
| 231 | +//go.mod |
| 232 | + |
| 233 | +module function |
| 234 | + |
| 235 | +go 1.14 |
| 236 | + |
| 237 | +require ( |
| 238 | + github.com/sirupsen/logrus v1.6.0 |
| 239 | +) |
| 240 | +``` |
| 241 | + |
| 242 | +```bash |
| 243 | +kubeless function deploy get-go-deps --runtime go1.14 --handler hellowithdeps.Hello --from-file hellowithdeps.go --dependencies go.mod |
| 244 | +``` |
208 | 245 |
|
209 | 246 | #### Server implementation
|
210 | 247 |
|
@@ -261,7 +298,7 @@ func Foo(event functions.Event, context functions.Context) (string, error) {
|
261 | 298 | }
|
262 | 299 | ```
|
263 | 300 |
|
264 |
| -If the function above has a timeout smaller than 5 seconds it will exit and the code after the `select{}` won't be executed. |
| 301 | +If the function above has a timeout smaller than 5 seconds it will exit and the code after the `select{}` won't be executed. |
265 | 302 |
|
266 | 303 | ### Java
|
267 | 304 |
|
@@ -462,13 +499,13 @@ public function foo(kubeless:Event event, kubeless:Context context) returns (str
|
462 | 499 |
|
463 | 500 | #### Description
|
464 | 501 |
|
465 |
| -The Ballerina functions should import the package `kubeless/kubeless`. This [package](https://central.ballerina.io/kubeless/kubeless) contains two types `Event` and `Context`. |
466 |
| - |
| 502 | +The Ballerina functions should import the package `kubeless/kubeless`. This [package](https://central.ballerina.io/kubeless/kubeless) contains two types `Event` and `Context`. |
| 503 | + |
467 | 504 | ```console
|
468 |
| -$ kubeless function deploy foo |
469 |
| - --runtime ballerina0.981.0 |
470 |
| - --from-file foo.bal |
471 |
| - --handler foo.foo |
| 505 | +$ kubeless function deploy foo |
| 506 | + --runtime ballerina0.981.0 |
| 507 | + --from-file foo.bal |
| 508 | + --handler foo.foo |
472 | 509 | ```
|
473 | 510 |
|
474 | 511 | When using the Ballerina runtime, it is possible to provide a configuration via `kubeless.toml` file. The values in kubeless.toml file are available for the function. The function(.bal file) and conf file should be in the same directory.
|
|
482 | 519 | $ zip -r -j foo.zip foo/
|
483 | 520 |
|
484 | 521 | $ kubeless function deploy foo
|
485 |
| - --runtime ballerina0.981.0 |
486 |
| - --from-file foo.zip |
| 522 | + --runtime ballerina0.981.0 |
| 523 | + --from-file foo.zip |
487 | 524 | --handler hellowithconf.foo
|
488 | 525 | ```
|
489 | 526 |
|
|
0 commit comments