Knative 快捷操作命令 Kn 介绍
kn 是 Knative 命令行操作客戶端。 通過 kn 可以方便的操作Knative 相關(guān)的資源。
安裝 Kn
可以通過官方獲取對應(yīng)的 Kn 二進制
? macOS
? Linux
? Windows
kn 會與 kubectl 使用同樣的config 文件,默認(rèn)使用 $HOME/.kube/config
服務(wù)管理
使用 Kn 命令可以執(zhí)行: list, create, delete, apply, 和 update 操作Knative services.
創(chuàng)建服務(wù)
使用 create 命令:
kn service create
示例:
使用 apply 命令:
kn service apply
示例:
查看服務(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-1606806762serving.knative.dev/lastModifier: 1041208914252405-1606806762creationTimestamp: "2020-12-09T06:07:41Z"generation: 2name: helloworld-gonamespace: defaultresourceVersion: "39555635"selfLink: /apis/serving.knative.dev/v1/namespaces/default/services/helloworld-gouid: 763e8214-7c2d-476c-bd88-40b32a30597d spec:template:metadata:annotations:client.knative.dev/user-image: registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8creationTimestamp: nullname: helloworld-go-cvclp-2spec:containerConcurrency: 0containers:- env:- name: TARGETvalue: knativeimage: registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8name: user-containerreadinessProbe:successThreshold: 1tcpSocket:port: 0resources: {}timeoutSeconds: 300traffic:- latestRevision: truepercent: 100 status:address:url: http://helloworld-go.default.svc.cluster.localconditions:- 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: RoutesReadylatestCreatedRevisionName: helloworld-go-cvclp-2latestReadyRevisionName: helloworld-go-cvclp-2observedGeneration: 2traffic:- latestRevision: truepercent: 100revisionName: helloworld-go-cvclp-2url: http://helloworld-go.default.example.com更新服務(wù)(創(chuàng)建新版本)
使用 update 命令:
kn service update NAME
示例:
使用 apply 也可進行更新服務(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 3mI 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
原文鏈接:https://developer.aliyun.com/article/779806?
版權(quán)聲明:本文內(nèi)容由阿里云實名注冊用戶自發(fā)貢獻,版權(quán)歸原作者所有,阿里云開發(fā)者社區(qū)不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。具體規(guī)則請查看《阿里云開發(fā)者社區(qū)用戶服務(wù)協(xié)議》和《阿里云開發(fā)者社區(qū)知識產(chǎn)權(quán)保護指引》。如果您發(fā)現(xiàn)本社區(qū)中有涉嫌抄襲的內(nèi)容,填寫侵權(quán)投訴表單進行舉報,一經(jīng)查實,本社區(qū)將立刻刪除涉嫌侵權(quán)內(nèi)容。總結(jié)
以上是生活随笔為你收集整理的Knative 快捷操作命令 Kn 介绍的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 程序员该知道的7个必经阶段
- 下一篇: 疫情之下的科技普惠:阿里云科技驱动中小企