Knative快捷操作命令Kn怎么用

今天就跟大家聊聊有關(guān)Knative快捷操作命令Kn 怎么用,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

“只有客戶發(fā)展了,才有我們的生存與發(fā)展!”這是成都創(chuàng)新互聯(lián)的服務(wù)宗旨!把網(wǎng)站當(dāng)作互聯(lián)網(wǎng)產(chǎn)品,產(chǎn)品思維更注重全局思維、需求分析和迭代思維,在網(wǎng)站建設(shè)中就是為了建設(shè)一個(gè)不僅審美在線,而且實(shí)用性極高的網(wǎng)站。創(chuàng)新互聯(lián)對(duì)成都做網(wǎng)站、網(wǎng)站建設(shè)、網(wǎng)站制作、網(wǎng)站開發(fā)、網(wǎng)頁設(shè)計(jì)、網(wǎng)站優(yōu)化、網(wǎng)絡(luò)推廣、探索永無止境。

kn 是 Knative 命令行操作客戶端。 通過 kn 可以方便的操作Knative 相關(guān)的資源。

安裝 Kn

可以通過官方獲取對(duì)應(yīng)的 Kn 二進(jìn)制

  • macOS

  • Linux

  • Windows

kn 會(huì)與 kubectl 使用同樣的config 文件,默認(rèn)使用 $HOME/.kube/config

服務(wù)管理

使用 Kn 命令可以執(zhí)行: list, create, delete, apply, 和 update 操作Knative services.

創(chuàng)建服務(wù)

使用 create 命令:
kn service create
示例:

$ kn service create helloworld-go --env TARGET=knative --image registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:73fbdd56
yuncs.com/knative-sample/helloworld-go:73fbdd56
Creating service 'helloworld-go' in namespace 'default':
  0.116s The Route is still working to reflect the latest desired specification.
  0.216s Configuration "helloworld-go" is waiting for a Revision to become ready.
  3.075s ...
  3.149s Ingress has not yet been reconciled.
  3.299s ...
  3.762s Ready to serve.
Service 'helloworld-go' created to latest revision 'helloworld-go-pyqqz-1' is available at URL:
http://helloworld-go.default.example.com

使用 apply 命令:
kn service apply
示例:

# Create an initial service with using 'kn service apply', if the service has not
# been already created
kn service apply s0 --image registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:73fbdd56
# Apply the service again which is a no-operation if none of the options changed
kn service apply s0 --image registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:73fbdd56
# Add an environment variable to your service. Note, that you have to always fully
# specify all parameters (in contrast to 'kn service update')
kn service apply s0 --image registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:73fbdd56 --env TARGET=knative
# Read the service declaration from a file
kn service apply s0 --filename my-svc.yml

查看服務(wù)

查詢服務(wù)列表示例:

kn service list
NAME            URL                                        LATEST                  AGE   CONDITIONS   READY   REASON
helloworld-go   http://helloworld-go.default.example.com   helloworld-go-pyqqz-1   55s   3 OK / 3     True

查詢服務(wù)詳情示例:

kn service describe helloworld-go
Name:       helloworld-go
Namespace:  default
Age:        14m
URL:        http://helloworld-go.default.example.com
Revisions:
  100%  @latest (helloworld-go-cvclp-2) [2](9m)
        Image:  registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8 (pinned to 032b80)
Conditions:
  OK TYPE                   AGE REASON
  ++ Ready                   9m
  ++ ConfigurationsReady     9m
  ++ RoutesReady             9m

或者以 yaml 方式展示詳情:

$ kn service describe helloworld-go -oyaml
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  annotations:
    serving.knative.dev/creator: 1041208914252405-1606806762
    serving.knative.dev/lastModifier: 1041208914252405-1606806762
  creationTimestamp: "2020-12-09T06:07:41Z"
  generation: 2
  name: helloworld-go
  namespace: default
  resourceVersion: "39555635"
  selfLink: /apis/serving.knative.dev/v1/namespaces/default/services/helloworld-go
  uid: 763e8214-7c2d-476c-bd88-40b32a30597d
spec:
  template:
    metadata:
      annotations:
        client.knative.dev/user-image: registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8
      creationTimestamp: null
      name: helloworld-go-cvclp-2
    spec:
      containerConcurrency: 0
      containers:
      - env:
        - name: TARGET
          value: knative
        image: registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8
        name: user-container
        readinessProbe:
          successThreshold: 1
          tcpSocket:
            port: 0
        resources: {}
      timeoutSeconds: 300
  traffic:
  - latestRevision: true
    percent: 100
status:
  address:
    url: http://helloworld-go.default.svc.cluster.local
  conditions:
  - lastTransitionTime: "2020-12-09T06:13:33Z"
    status: "True"
    type: ConfigurationsReady
  - lastTransitionTime: "2020-12-09T06:13:34Z"
    status: "True"
    type: Ready
  - lastTransitionTime: "2020-12-09T06:13:34Z"
    status: "True"
    type: RoutesReady
  latestCreatedRevisionName: helloworld-go-cvclp-2
  latestReadyRevisionName: helloworld-go-cvclp-2
  observedGeneration: 2
  traffic:
  - latestRevision: true
    percent: 100
    revisionName: helloworld-go-cvclp-2
  url: http://helloworld-go.default.example.com

更新服務(wù)(創(chuàng)建新版本)

使用 update 命令:
kn service update NAME
示例:

$ kn service update helloworld-go --image registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8
Updating Service 'helloworld-go' in namespace 'default':
  3.609s Traffic is not yet migrated to the latest revision.
  3.631s Ingress has not yet been reconciled.
  4.066s Ready to serve.
Service 'helloworld-go' updated to latest revision 'helloworld-go-cvclp-2' is available at URL:
http://helloworld-go.default.example.com

使用 apply 也可進(jìn)行更新服務(wù)

kn service apply
# Add an environment variable to your service. Note, that you have to always fully
# specify all parameters (in contrast to 'kn service update')
kn service apply s0 --image registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8 --env TARGET=knative

刪除服務(wù)

示例:

kn service delete helloworld-go

版本管理

查看版本

kn revision list
NAME                    SERVICE         TRAFFIC   TAGS   GENERATION   AGE     CONDITIONS   READY     REASON
helloworld-go-cvclp-2   helloworld-go   100%             2            40s     4 OK / 4     True
helloworld-go-pyqqz-1   helloworld-go                    1            6m29s   3 OK / 4     True

查看版本詳情

$ kn revision describe helloworld-go-cvclp-2
Name:       helloworld-go-cvclp-2
Namespace:  default
Age:        3m
Image:      registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8 (pinned to 032b80)
Env:        TARGET=knative
Service:    helloworld-go
Conditions:
  OK TYPE                  AGE REASON
  ++ Ready                  3m
  ++ ContainerHealthy       3m
  ++ ResourcesAvailable     3m
   I Active                 2m NoTraffic

刪除版本

$ kn revision delete helloworld-go-pyqqz-1
Revision 'helloworld-go-pyqqz-1' deleted in namespace 'default'.

其它

除了上面介紹的 service、revision。 Kn 還支持如下的資源操作, 有興趣的可以自己試用一下。

  • kn broker - 管理事件 brokers

  • kn channel - 管理事件 channels

  • kn route - 管理服務(wù)路由 routes

  • kn source - 管理事件源 sources

  • kn trigger - 管理事件 triggers

看完上述內(nèi)容,你們對(duì)Knative快捷操作命令Kn 怎么用有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。

名稱欄目:Knative快捷操作命令Kn怎么用
標(biāo)題路徑:http://bm7419.com/article16/jdejgg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司外貿(mào)網(wǎng)站建設(shè)、靜態(tài)網(wǎng)站網(wǎng)站設(shè)計(jì)、品牌網(wǎng)站設(shè)計(jì)、小程序開發(fā)

廣告

聲明:本網(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)站網(wǎng)頁設(shè)計(jì)