serverless-kubeless

This plugin enables support for Kubeless within the Serverless Framework.

  • 所有者: serverless/serverless-kubeless
  • 平台:
  • 许可证: Apache License 2.0
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Kubeless Serverless Plugin

This plugin brings Kubeless support within the Serverless Framework.

Kubeless is a Kubernetes-native Serverless solution.

Pre requisites

Make sure you have a kubernetes endpoint running and kubeless installed. You can find the installation intructions here.

Once you have Kubeless running in your cluster you can install serverless

$ npm install serverless -g

Try out the example

Clone this repo and check the example function

$ git clone https://github.com/serverless/serverless-kubeless
$ cd examples/get-python
$ cat serverless.yml
service: hello

provider:
  name: kubeless
  runtime: python2.7

plugins:
  - serverless-kubeless

functions:
  hello:
    description: 'Hello function'
    handler: handler.hello

Download dependencies

$ npm install

Deploy function.

$ serverless deploy
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Deploying function hello...
Serverless: Function hello successfully deployed

The function will be deployed to k8s via kubeless.

$ kubectl get function
NAME      KIND
hello     Function.v1.k8s.io

$ kubectl get po
NAME                     READY     STATUS    RESTARTS   AGE
hello-1815473417-1ttt7   1/1       Running   0          1m

Now you will be able to call the function:

$ serverless invoke -f hello -l
Serverless: Calling function: hello...
--------------------------------------------------------------------
hello world

You can also check the logs for the function:

$ serverless logs -f hello
172.17.0.1 - - [12/Jul/2017:09:47:18 +0000] "GET /healthz HTTP/1.1" 200 2 "" "Go-http-client/1.1" 0/118
172.17.0.1 - - [12/Jul/2017:09:47:21 +0000] "GET /healthz HTTP/1.1" 200 2 "" "Go-http-client/1.1" 0/93
172.17.0.1 - - [12/Jul/2017:09:47:24 +0000] "GET /healthz HTTP/1.1" 200 2 "" "Go-http-client/1.1" 0/108
172.17.0.1 - - [12/Jul/2017:09:47:25 +0000] "GET / HTTP/1.1" 200 11 "" "" 0/316

Or you can obtain the function information:

$ serverless info
Service Information "hello"
Cluster IP:  10.0.0.51
Type:  ClusterIP
Ports:
  Name:  http-function-port
  Protocol:  TCP
  Port:  8080
  Target Port:  8080
Function Info
Description: Hello function
Handler:  handler.hello
Runtime:  python2.7
Trigger: HTTP
Dependencies:

You can access the function through its HTTP interface as well using kubectl proxy and accessing:

$ curl http://127.0.0.1:8001/api/v1/namespaces/default/services/hello/proxy/
hello world

If you have a change in your function and you want to redeploy it you can run:

$ serverless deploy function -f hello
Serverless: Redeploying hello...
Serverless: Function hello successfully deployed

Finally you can remove the function.

$ serverless remove
Serverless: Removing function: hello...
Serverless: Function hello successfully deleted

Kubernetes secrets

Kubernetes secret objects let you store and manage sensitive information, such as passwords, OAuth tokens, and ssh keys.
Putting this information in a secret is safer and more flexible than putting it verbatim in a Pod definition or in a container image. To use secrets follow the next steps:

  1. Create a K8s secret:
    kubectl create secret generic secret-file --from-file=secret.txt -n namespace-name

  2. Add the secret key into the provider definition in the serverless.yml file below the secrets key. You can specify an array of secrets and they will be mounted at root level in the pod file system using the path /<secret-name>:

provider:
  name: kubeless
  ....
  secrets:
     - secret-file
  1. Now inside your pod, you will be able to access the route /secret-file/secret.txt.

主要指标

概览
名称与所有者serverless/serverless-kubeless
主编程语言JavaScript
编程语言JavaScript (语言数: 3)
平台
许可证Apache License 2.0
所有者活动
创建于2017-05-18 08:03:42
推送于2024-12-09 15:32:16
最后一次提交2024-12-09 07:32:16
发布数36
最新版本名称v0.11.1 (发布于 )
第一版名称v0.1.11 (发布于 )
用户参与
星数304
关注者数31
派生数80
提交数425
已启用问题?
问题数105
打开的问题数39
拉请求数125
打开的拉请求数6
关闭的拉请求数6
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?