1. 程式人生 > >serverless框架之開源openfaas部署

serverless框架之開源openfaas部署

kubernetes version

[[email protected] chart]# kubectl version 
Client Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.0-168+f47446a730ca03", GitCommit:"f47446a730ca037473fb3bf0c5abeea648c1ac12", GitTreeState:"clean", BuildDate:"2018-08-25T21:05:52Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.0-168+f47446a730ca03", GitCommit:"f47446a730ca037473fb3bf0c5abeea648c1ac12", GitTreeState:"clean", BuildDate:"2018-08-25T21:05:52Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}

安裝helm

安裝helm工具請參考helm 安裝

下載原始碼

git clone https://github.com/openfaas/faas-netes.git
cd faas-netes/chart

helm install openfaas/
[[email protected] chart]# helm install openfaas/
Chart.yaml   OWNERS       README.md    templates/   values.yaml  
[[email protected] chart]# helm install openfaas/
NAME:   eager-wildebeest
LAST DEPLOYED: Thu Nov 15 19:57:07 2018
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/ConfigMap
NAME                 AGE
alertmanager-config  0s
prometheus-config    0s

==> v1/ServiceAccount
eager-wildebeest-controller  0s

==> v1beta1/ClusterRole
eager-wildebeest-controller  0s

==> v1beta1/ClusterRoleBinding
eager-wildebeest-controller  0s

==> v1/Service
alertmanager      0s
gateway-external  0s
gateway           0s
nats              0s
prometheus        0s

==> v1beta1/Deployment
alertmanager  0s
faas-idler    0s
gateway       0s
nats          0s
prometheus    0s
queue-worker  0s

==> v1/Pod(related)

NAME                           READY  STATUS             RESTARTS  AGE
alertmanager-574fbd97f7-76tzr  0/1    ContainerCreating  0         0s
faas-idler-f656b895d-nt9wp     0/1    ContainerCreating  0         0s
gateway-5644677dc8-jnqpn       0/2    ContainerCreating  0         0s
nats-74fc8944fb-jpft2          0/1    ContainerCreating  0         0s
prometheus-7dbc7d9f79-vnp58    0/1    ContainerCreating  0         0s
queue-worker-566fb99ff8-ttlwj  0/1    ContainerCreating  0         0s


NOTES:
To verify that openfaas has started, run:

  kubectl --namespace=default get deployments -l "release=eager-wildebeest, app=openfaas"

[
[email protected]
chart]# kubectl --namespace=default get deployments -l "release=eager-wildebeest, app=openfaas" NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE alertmanager 1 1 1 0 27s gateway 1 1 1 0 27s nats 1 1 1 0 27s prometheus 1 1 1 0 27s queue-worker 1 1 1 0 27s

部署過程中會發現以下錯誤,刪除掉即可

gateway-5644677dc8-jnqpn         1/2       ErrImagePull       0          3m

部署結果檢視

[[email protected] chart]# kubectl get svc 
NAME               TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
alertmanager       ClusterIP   10.254.7.6      <none>        9093/TCP         13m
gateway            ClusterIP   10.254.6.144    <none>        8080/TCP         13m
gateway-external   NodePort    10.254.3.106    <none>        8080:31112/TCP   13m
nats               ClusterIP   10.254.14.142   <none>        4222/TCP         13m
prometheus         ClusterIP   10.254.19.240   <none>        9090/TCP         13m

[[email protected] chart]# kubectl get pods -owide
NAME                             READY     STATUS             RESTARTS   AGE       IP              NODE           NOMINATED NODE
alertmanager-574fbd97f7-76tzr    1/1       Running            0          30m       10.253.62.144   master-47-34   <none>
faas-idler-f656b895d-nt9wp       1/1       Running            5          30m       10.253.109.57   slave-47-33    <none>
gateway-5644677dc8-jnqpn         2/2       Running            2          30m       10.253.63.213   master-47-36   <none>
nats-74fc8944fb-jpft2            1/1       Running            0          30m       10.253.62.146   master-47-34   <none>
prometheus-7dbc7d9f79-vnp58      1/1       Running            0          30m       10.253.63.230   master-47-36   <none>
queue-worker-566fb99ff8-rd2kt    1/1       Running            0          25m       10.253.109.49   slave-47-33    <none>

從瀏覽器訪問gateway-5644677dc8-jnqpn所在的節點的31112埠
open

部署完畢

參考
openfaas deployment on kubernetes