FaaS踩坑之fission使用记录
1. fission命令
1 | function, fn Create, update and manage functions |
2. 使用记录——function
- 已有函数hello.js
1 |
|
- 为函数创建route(http请求时用到):
1 | fission route create --function hello --url /hello |
- 创建基于pool executor 的函数
1 | fission fn create --name hello --code hello.js --env node --executortype poolmgr |
点击函数的url 获得结果
1
2curl http://$FISSION_ROUTER/hello
Hello, world!指定函数最大/最小规模
1
fission fn create --name hello --code hello.js --env node --minscale 1 --maxscale 5 --executortype newdeploy
更新函数:
1
fission fn update --name hello --code ../hello.js
测试函数:
1
fission fn test --name hello
函数运行出错,输出:
1
Error calling function hello: 500 Internal server error (fission)
查看函数运行日志:
1
fission fn logs --name hello
building function
1 | sourcepkg/ |
11.compiled artifacts with Fission
3 使用记录————environment
- 准备环境
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
在启动环境的时候设置builder
1
fission env create --name python --image fission/python-env:latest --builder fission/python-builder:latest
查看env信息
1
2fission env list
fission env get --name node
使用记录————Controlling Function Execution
安装go
安装 hey
用hey
HorizontalPodAutoscaler
4.使用记录————trigger
http trigger:通过http get到一个函数
time trigger:定时执行函数
message queue trigger:基于message queue来执行函数
(NATS and Azure Storage Queue are supported queues.)
5.使用记录————打包
打包源码
1
fission package create --sourcearchive demo-src-pkg.zip --env pythonsrc --buildcmd "./build.sh"
打包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.使用问题记录:
fission host路径问题,创建环境(go,python,js…),创建executors和函数(创建pod),创建trigger(调用函数)因为第二步和第三步存在依赖关系顺序不能反
1
2
3fission 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,fission创建package的时候有权限问题builder不起来,用sh 不用./ 或者用chmod给文件加权限777
1
chmod –R 777 *
测试时 ,需要把$FISSION_ROUTER换了,用的minikube直接换成它的地址,用的k8s换成外部ip
1
2curl http://$FISSION_ROUTER/hello 换成
curl http://35.194.204.59/hello按照fission命令删除函数以及删除trigger后,发现相关的pod没有被删除
1
fission fn delete --name hellopy
build的路径问题未解决:
1
Error starting cmd: exec: "sh build.sh": executable file not found in $PATH
查看builder日志:
1
2k -n fission-builder logs -f py3-4214348-59555d9bd8-ks7m4 builder 换成
kubectl logs python-39799-58b5b4f844-np94r -n fission-builder --container=builder创建 fn,env,ht等时,一个属性赋值错误时:依然被创建会存在,但会使用失败
- 测试时的hey 和 k:需要安装go ,hey ,HorizontalPodAutoscaler
- 创建env时,在这里找镜像:https://docs.fission.io/0.6.0/concepts/environments/
- packge创建失败?感觉builder有问题
1
Build timeout due to environment builder not ready