久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

如何使用Kubeless Serverless Plugin部署與管理Kubeless 函數

160次閱讀
沒有評論

共計 2455 個字符,預計需要花費 7 分鐘才能閱讀完成。

如何使用 Kubeless Serverless Plugin 部署與管理 Kubeless 函數,相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。

Kubeless 是一個 Kubernetes 原生的 Serverless 解決方案。

Serverless Framework 是一個命令行工具,支持將函數部署到不同平臺(如:AWS Lambda、Azure Functions、Google CloudFunctions、騰訊云云函數 SCF 等等)并對它進行管理。

Kubeless Serverless Plugin 使得通過  Serverless Framework 部署函數到 Kubeless 成為可能。

下面將介紹使用 Kubeless Serverless Plugin 部署與管理 Kubeless 函數。

環境說明

操作系統:macOS

Kubernetes 版本:v1.15.5

Kubeless 版本:v1.0.7

安裝 serverless

serverless 可以通過 npm 命令安裝:

$ npm install serverless -g

示例體驗

使用 git 克隆 serverless-kubeless 倉庫,并查看示例函數。

serverless.yml 中有幾個關鍵字段:service、provider、plugins、functions,其中 provider 下面還有 name 和 runtime。

從 package.json 文件內容中可以看出依賴中包括 serverless-kubeless。

$ git clone https://github.com/serverless/serverless-kubeless
$ cd serverless-kubeless/examples/get-python
$ cat serverless.yml
service: hello

  version :  1.0.0 ,   description :  Example function for serverless kubeless ,   dependencies : {   serverless-kubeless :  ^0.7.0  },   devDependencies : {},   scripts : {   test :  echo \ Error: no test specified\    exit 1  },   author :  ,   license :  Apache-2.0 }

下載依賴,這里用到了淘寶源:

$ npm install --registry=https://registry.npm.taobao.org

部署函數:

$ serverless deploy
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Deploying function hello...
Serverless: Function hello successfully deployed

查看函數狀態:

$ kubectl get function
NAME AGE
hello 2m1s
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
hello-68d57655b4-cfk6b 1/1 Running 0 2m16s

調用函數:

$ serverless invoke -f hello -l
Serverless: Calling function: hello...
--------------------------------------------------------------------
hello world

查看函數日志:

$ serverless logs -f hello
10.1.0.1 - - [09/Oct/2020:09:23:17 +0000]  GET / HTTP/1.1  200 11     0/10532
10.1.0.1 - - [09/Oct/2020:09:23:37 +0000]  GET /healthz HTTP/1.1  200 2    kube-probe/1.16+  0/138
10.1.0.1 - - [09/Oct/2020:09:24:07 +0000]  GET /healthz HTTP/1.1  200 2    kube-probe/1.16+  0/182

獲取函數信息:

$ serverless info
Service Information  hello 
Cluster IP: 10.107.27.134
Type: ClusterIP
Ports:
 Name: http-function-port
 Protocol: TCP
 Port: 8080
 Target Port: 8080
Function Info
Description: Hello function
Labels:
 created-by: kubeless
 function: hello
Handler: handler.hello
Runtime: python2.7
Dependencies:

修改函數后,重新部署:

$ serverless deploy function -f hello

這里遇到了問題,導致函數重新部署失敗,詳情參見:https://github.com/serverless/serverless-kubeless/issues/201

刪除函數:

$ serverless remove
Serverless: Removing function: hello...

看完上述內容,你們掌握如何使用 Kubeless Serverless Plugin 部署與管理 Kubeless 函數的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注丸趣 TV 行業資訊頻道,感謝各位的閱讀!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-08-16發表,共計2455字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 杭锦后旗| 楚雄市| 苏尼特左旗| 彭山县| 灵宝市| 称多县| 吉水县| 永修县| 中牟县| 梁山县| 忻州市| 延吉市| 田东县| 将乐县| 昔阳县| 阿拉善右旗| 河北省| 天祝| 黔南| 辽阳市| 凤山县| 正安县| 呼图壁县| 渝北区| 镇远县| 耿马| 永昌县| 扬州市| 象山县| 黑龙江省| 同江市| 彭州市| 彭山县| 泗水县| 鄂托克前旗| 万源市| 东平县| 琼结县| 平塘县| 明水县| 阿拉善左旗|