参考官网:https://kubeless.io/docs/quick-start/
- 安装kubeless(WITH RBAC ENABLED)
export RELEASE=$(curl -s https://api.github.com/repos/kubeless/kubeless/releases/latest | grep tag_name | cut -d '"' -f 4)
kubectl create ns kubeless
kubectl create -f https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless-$RELEASE.yaml
kubectl create -f https://raw.githubusercontent.com/kubeless/kubeless-ui/master/k8s.yaml
- k8s服务器中安装CLI工具
export OS=$(uname -s| tr '[:upper:]' '[:lower:]')
curl -OL https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless_$OS-amd64.zip && \
unzip kubeless_$OS-amd64.zip && \
sudo mv bundles/kubeless_$OS-amd64/kubeless /usr/local/bin/
- 事例参考 https://github.com/kubeless/kubeless/tree/master/examples
- 部署function
kubeless function deploy hello --runtime python2.7 \
--from-file test.py \
--handler test.hello
- 调用。kubeless
kubeless function call hello --data 'Hello world!'
- 也可以通过UI来调用
- 默认是导出为k8s的service,
ClusterIP
类型。所以可以在kubernetes内部中调用
$ curl http://hello:8080 -X POST -d 'TSET!!'
TSET!!
- 也可以导出ingress。参考官方网站
https://kubeless.io/docs/http-triggers/
。支持情况各不相同,如不行,手动创建一个igress文件也可 - 自定义运行环境参考 https://my.oschina.net/u/160697/blog/4772731