1. fission命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function, fn                  Create, update and manage functions

httptrigger, ht, route Manage HTTP triggers (routes) for functions

timetrigger, tt, timer Manage Time triggers (timers) for functions

mqtrigger, mqt, messagequeue Manage message queue triggers for functions

environment, env Manage environments

watch, w Manage watches

package, pkg Manage packages

spec, specs Manage a declarative app specification

upgrade Upgrade tool from fission v0.1

tpr2crd Migrate tool for TPR to CRD

help, h Shows a list of commands or help for one command

2. 使用记录——function

  1. 已有函数hello.js
1
2
3
4
5
6
7

module.exports = async function(context) {
return {
status: 200,
body: "Hello, world!\n"
};
}
  1. 为函数创建route(http请求时用到):
1
fission route create --function hello --url /hello
  1. 创建基于pool executor 的函数
1
fission fn create --name hello --code hello.js --env node --executortype poolmgr
  1. 点击函数的url 获得结果

    1
    2
    curl http://$FISSION_ROUTER/hello
    Hello, world!
  2. 指定函数最大/最小规模

    1
    fission fn create --name hello --code hello.js --env node --minscale 1 --maxscale 5  --executortype newdeploy
  3. 更新函数:

    1
    fission fn update --name hello --code ../hello.js
  4. 测试函数:

    1
    fission fn test --name hello
  5. 函数运行出错,输出:

    1
    Error calling function hello: 500 Internal server error (fission)
  6. 查看函数运行日志:

    1
    fission fn logs --name hello
  7. building function

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
sourcepkg/
├── __init__.py
├── build.sh
├── requirements.txt
└── user.py

$ cat user.py
import sys
import yaml

document = """
a: 1
b:
c: 3
d: 4
"""

def main():
return yaml.dump(yaml.load(document))

$ cat requirements.txt
pyyaml

$ cat build.sh
#!/bin/sh
pip3 install -r ${SRC_PKG}/requirements.txt -t ${SRC_PKG} && cp -r ${SRC_PKG} ${DEPLOY_PKG}
$zip -jr demo-src-pkg.zip sourcepkg/
adding: __init__.py (stored 0%)
adding: build.sh (deflated 24%)
adding: requirements.txt (stored 0%)
adding: user.py (deflated 25%)

fission fn create --name hellopy --env python --src demo-src-pkg.zip --entrypoint "user.main" --buildcmd "sh build.sh"


$ fission route create --function hellopy --url /hellopy



fission fn update --name hellopy --env python --src demo-src-pkg.zip --entrypoint "user.main" --buildcmd “sh build.sh”

11.compiled artifacts with Fission

3 使用记录————environment

  1. 准备环境
    1
    fission env create --name node --image fission/node-env:0.4.0 --mincpu 40 --maxcpu 80 --minmemory 64 --maxmemory 128 --poolsize 4

设置环境,语言镜像,环境中支持几个pre-warmed pod

  1. 在启动环境的时候设置builder

    1
    fission env create --name python --image fission/python-env:latest --builder fission/python-builder:latest
  2. 查看env信息

    1
    2
    fission env list
    fission env get --name node

使用记录————Controlling Function Execution

安装go
安装 hey

  1. 用hey

  2. HorizontalPodAutoscaler

4.使用记录————trigger

  1. http trigger:通过http get到一个函数

  2. time trigger:定时执行函数

  3. message queue trigger:基于message queue来执行函数

(NATS and Azure Storage Queue are supported queues.)

5.使用记录————打包

  1. 打包源码

    1
    fission package create --sourcearchive demo-src-pkg.zip --env pythonsrc --buildcmd "./build.sh"
  2. 打包deployment

    1
    fission env create --name pythondeploy --image fission/python-env:latest --builder fission/python-builder:latest --mincpu 40 --maxcpu 80 --minmemory 64 --maxmemory 128 --poolsize 2

6.使用问题记录:

  1. fission host路径问题,创建环境(go,python,js…),创建executors和函数(创建pod),创建trigger(调用函数)因为第二步和第三步存在依赖关系顺序不能反

    1
    2
    3
    fission env create --name nodejs --image fission/node-env:0.6.0
    fission route create --function hello --url /hello
    fission fn create --name hello --code hello.js --env nodejs --executortype poolmgr,
  2. fission创建package的时候有权限问题builder不起来,用sh 不用./ 或者用chmod给文件加权限777

    1
    chmod –R 777 *
  3. 测试时 ,需要把$FISSION_ROUTER换了,用的minikube直接换成它的地址,用的k8s换成外部ip

    1
    2
    curl http://$FISSION_ROUTER/hello 换成
    curl http://35.194.204.59/hello
  4. 按照fission命令删除函数以及删除trigger后,发现相关的pod没有被删除

    1
    fission fn delete --name hellopy
  5. build的路径问题未解决:

    1
    Error starting cmd: exec: "sh build.sh": executable file not found in $PATH
  6. 查看builder日志:

    1
    2
    k -n fission-builder logs -f py3-4214348-59555d9bd8-ks7m4 builder 换成
    kubectl logs python-39799-58b5b4f844-np94r -n fission-builder --container=builder
  7. 创建 fn,env,ht等时,一个属性赋值错误时:依然被创建会存在,但会使用失败

  8. 测试时的hey 和 k:需要安装go ,hey ,HorizontalPodAutoscaler
  9. 创建env时,在这里找镜像:https://docs.fission.io/0.6.0/concepts/environments/
  10. packge创建失败?感觉builder有问题
    1
    Build timeout due to environment builder not ready

Comments

⬆︎TOP