学习FaaS的步骤,你需要先了解docker的虚拟化技术和Kubernetes (k8s) 的docker容器管理技术,当这两方面的知识储备完后,你就可以学习fission的框架和设计理念了。FaaS是一种云计算的概念,将函数作为一种服务,而这种概念的代码实现框架有OpenFaaS、fission等,咱们这里介绍fission。
docker的总结教程:https://blog.csdn.net/qccz123456/article/details/83342253 , 介绍了如何使用docker进行各种操作容器;
k8s官方翻译的学习教程:https://blog.csdn.net/kikajack/article/details/80208340 , 介绍了k8s中的各种概念和如何管理docker的。
最后学习fission的教程如下:
(1)了解Faas的大致介绍:https://yq.aliyun.com/articles/175225
(2)了解fission的使用方法:https://www.kubernetes.org.cn/2523.html
(3)掌握fission的具体操作和细节:https://docs.fission.io/0.12.0/
(4)补充学习一些fission的知识:https://lingxiankong.github.io/2017-03-05-faas-fission.html
kubelet:运行在cluster所有节点上,负责启动POD和容器
kubeadm:用于初始化cluster
kubectl:kubectl是kubenetes命令行工具,通过kubectl可以部署和管理应用,查看各种资源,创建,删除和更新组件
kubectl usage
# kubectl version Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.2", GitCommit:"17c77c7898218073f14c8d573582e8d2313dc740", GitTreeState:"clean", BuildDate:"2018-10-24T06:54:59Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.2", GitCommit:"17c77c7898218073f14c8d573582e8d2313dc740", GitTreeState:"clean", BuildDate:"2018-10-24T06:43:59Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"} # kubectl -h kubectl controls the Kubernetes cluster manager. Find more information at: https://kubernetes.io/docs/reference/kubectl/overview/ Basic Commands (Beginner): create Create a resource from a file or from stdin. expose Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service run Run a particular image on the cluster set Set specific features on objects Basic Commands (Intermediate): explain Documentation of resources get Display one or many resources edit Edit a resource on the server delete Delete resources by filenames, stdin, resources and names, or by resources and label selector Deploy Commands: rollout Manage the rollout of a resource scale Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job autoscale Auto-scale a Deployment, ReplicaSet, or ReplicationController Cluster Management Commands: certificate Modify certificate resources. cluster-info Display cluster info top Display Resource (CPU/Memory/Storage) usage. cordon Mark node as unschedulable uncordon Mark node as schedulable drain Drain node in preparation for maintenance taint Update the taints on one or more nodes Troubleshooting and Debugging Commands: describe Show details of a specific resource or group of resources logs Print the logs for a container in a pod attach Attach to a running container exec Execute a command in a container port-forward Forward one or more local ports to a pod proxy Run a proxy to the Kubernetes API server cp Copy files and directories to and from containers. auth Inspect authorization Advanced Commands: apply Apply a configuration to a resource by filename or stdin patch Update field(s) of a resource using strategic merge patch replace Replace a resource by filename or stdin wait Experimental: Wait for a specific condition on one or many resources. convert Convert config files between different API versions Settings Commands: label Update the labels on a resource annotate Update the annotations on a resource completion Output shell completion code for the specified shell (bash or zsh) Other Commands: alpha Commands for features in alpha api-resources Print the supported API resources on the server api-versions Print the supported API versions on the server, in the form of "group/version" config Modify kubeconfig files plugin Provides utilities for interacting with plugins. version Print the client and server version information Usage: kubectl [flags] [options] # kubectl -n fission get pods NAME READY STATUS RESTARTS AGE controller-85684bd4bb-tjdpx 1/1 Running 3 6d18h redis-0 1/1 Running 2 6d18h router-59db57d6f7-267pd 1/1 Running 4 6d18h ... # kubectl --namespace fission get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE controller NodePort 10.102.31.183 80:31313/TCP 6d19h redis ClusterIP 10.109.250.78 6379/TCP 6d19h router LoadBalancer 10.101.120.94 80:32164/TCP 6d19h # kubectl --namespace fission get svc router NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE router LoadBalancer 10.101.120.94 80:32164/TCP 6d19h # export FISSION_URL=10.239.85.153:31313 # export FISSION_ROUTER=10.239.85.153:32164 # kubectl -n fission logs redis-0 ... 1:M 21 Nov 07:02:14.719 * The server is now ready to accept connections on port 6379 # kubectl get nodes -o=wide # kubectl get pods --all-namespaces -o=wide # kubectl get services --all-namespaces -o=wide # kubectl get pods,services --all-namespaces -o=wide # kubectl get deployments --all-namespaces -o=wide # kubectl get all --all-namespaces # kubectl get pods --all-namespaces # kubectl describe pod -n fission-function # kubectl -n fission-function
fussion usage
# fission env -h NAME: fission environment - Manage environments USAGE: fission environment command [command options] [arguments...] COMMANDS: create, add Add an environment get Get environment details update Update environment delete Delete environment list List all environments # fission fn -h NAME: fission function - Create, update and manage functions USAGE: fission function command [command options] [arguments...] COMMANDS: create Create new function (and optionally, an HTTP route to it) get Get function source code getmeta Get function metadata update Update function source code delete Delete function list List all functions in a namespace if specified, else, list functions across all namespaces logs Display function logs test Test a function # fission route -h NAME: fission httptrigger - Manage HTTP triggers (routes) for functions USAGE: fission httptrigger command [command options] [arguments...] COMMANDS: create, add Create HTTP trigger get Get HTTP trigger update Update HTTP trigger delete Delete HTTP trigger list List HTTP triggers # fission env list # fission fn list # fission route list # fission env create --name nodejs --image fission/node-env (If environment doesn’t exist) # curl -LO https://raw.githubusercontent.com/fission/fission/master/examples/nodejs/hello.js # fission fn create --name hello --env nodejs --code hello.js # fission fn test --name hello # fission route create --function hello --url /hello # curl http://$FISSION_ROUTER/hello # fission env get --name nodejs # fission route delete -name hello # fission fn delete -name hello # fission env delete -name hello # fission env create --name python --image fission/python-env (If environment doesn’t exist) # fission fn create --name hello --env python --code hello.py –-url /hello --method GET # fission fn test --name hello # fission route create --function hello --url /hello # curl http://$FISSION_ROUTER/hello
fission route delete -name f9513731-0757-4912-b29b-56111cf9ed6e fission fn delete -name xnmt fission env delete -name enmt cd /root/ellisrm/nmt/ /root/ellisrm/get_logs.sh > /dev/null /root/ellisrm/get_logs.sh > log__nmt_env-no_fn-no_route-no_curl-no fission env create --name enmt --image 10.105.159.217:2501/rob-nmt:latest --poolsize 1 --version 3 /root/ellisrm/get_logs.sh > log__nmt_env-enmt_fn-no_route-no_curl-no fission fn create --code requestdata.py --name xnmt --entrypoint requestdata.main --env enmt --executortype newdeploy --minscale 1 --maxscale 1 --targetcpu 50 /root/ellisrm/get_logs.sh > /home/faas-master/fission_log/log__nmt_env-enmt_fn-xnmt_route-no_curl-no fission route create --function xnmt --url /nmt /root/ellisrm/get_logs.sh > /home/faas-master/fission_log/log__nmt_env-enmt_fn-xnmt_route-xnmt_curl-no curl "http://$FISSION_ROUTER/nmt?key=hello+world" /root/ellisrm/get_logs.sh > /home/faas-master/fission_log/log__nmt_env-enmt_fn-xnmt_route-xnmt_curl-nmt curl "http://$FISSION_ROUTER/nmt?key=hello+world" /root/ellisrm/get_logs.sh > /home/faas-master/fission_log/log__nmt_env-enmt_fn-xnmt_route-xnmt_curl-nmt2 curl "http://$FISSION_ROUTER/nmt?key=hello+world" /root/ellisrm/get_logs.sh > /home/faas-master/fission_log/log__nmt_env-enmt_fn-xnmt_route-xnmt_curl-nmt3
集群需要其他的一些设置,设置ip,对齐集群时间等:
配置网卡ip
清除原先设置的ip:ip addr flush dev eth0
设置ip:
Ubuntu: ifconfig eth0 192.168.0.1/24
ifconfig
CentOS: ip addr add 192.168.0.1/24 dev eth0
ip addr show
master eno2 <—> extern 10.239.85.153
node1 eno2 <—> extern 10.239.85.167
node2 eno2 <—> extern 10.239.85.168
192.168.0.1 master enp175s0f0 <—> node1 eno1 192.168.0.2
192.168.10.1 master enp175s0f1 <—> node2 eno1 192.168.10.2
配置NTP服务器:
(1)先关闭防火墙:
https://www.jianshu.com/p/d6414b5295b8
(2)配置NTP服务器和客户端并启动服务器
http://www.cnblogs.com/ivictor/p/3622081.html
https://blog.csdn.net/gycool21/article/details/51746174
(3)设置/etc/crontab,每多少时间重新校准一次时间
sudo service cron reload