如何使用KubelessServerlessPlugin部署與管理Kubeless函數(shù)

如何使用Kubeless Serverless Plugin部署與管理Kubeless 函數(shù),相信很多沒有經(jīng)驗(yàn)的人對(duì)此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。

創(chuàng)新互聯(lián)是專業(yè)的吳興網(wǎng)站建設(shè)公司,吳興接單;提供成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì),網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行吳興網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!

Kubeless 是一個(gè) Kubernetes 原生的 Serverless 解決方案。

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

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

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

環(huán)境說明

操作系統(tǒng):macOS

Kubernetes 版本:v1.15.5

Kubeless 版本:v1.0.7

安裝 serverless

serverless 可以通過 npm 命令安裝:

$ npm install serverless -g

示例體驗(yàn)

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

serverless.yml 中有幾個(gè)關(guān)鍵字段:service、provider、plugins、functions,其中 provider 下面還有 name 和 runtime。

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

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


provider:
  name: kubeless
  runtime: python2.7


plugins:
  - serverless-kubeless


functions:
  hello:
    description: 'Hello function'
    handler: handler.hello
$ cat package.json
{
  "name": "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

部署函數(shù):

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

查看函數(shù)狀態(tài):

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

調(diào)用函數(shù):

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


查看函數(shù)日志:

$ 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

獲取函數(shù)信息:

$ 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:

修改函數(shù)后,重新部署:

$ serverless deploy function -f hello

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

刪除函數(shù):

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

看完上述內(nèi)容,你們掌握如何使用Kubeless Serverless Plugin部署與管理Kubeless 函數(shù)的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

新聞標(biāo)題:如何使用KubelessServerlessPlugin部署與管理Kubeless函數(shù)
網(wǎng)頁地址:http://www.muchs.cn/article32/ghoepc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、、手機(jī)網(wǎng)站建設(shè)外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站收錄、建站公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司