knative-常用专用命令
安装命令 kn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1. 安装
linux
curl -sL https://github.com/knative/client/releases/latest/download/kn-linux-amd64 --output kn
macOS:
curl -sL https://github.com/knative/client/releases/latest/download/kn-macos-amd64 --output kn
或者
brew install knative/client/kn
2. 授权
chmod u+x kn
3. 验证
kn version
常用命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 列出当前ksvc的列表,及流量切换比例
> kn revision list -n prod
==================================================================
NAME SERVICE TRAFFIC TAGS GENERATION AGE CONDITIONS READY REASON
aiserver-airwaybill-extract-multimodal-00001 aiserver-airwaybill-extract-multimodal 100% 1 145d 4 OK / 4 True
aiserver-bge-00003 aiserver-bge 100% 3 110d 4 OK / 4 True
aiserver-bge-00002 aiserver-bge 2 110d 3 OK / 4 True
aiserver-bge-00001 aiserver-bge 1 110d 3 OK / 4 True
aiserver-br-extract-00003 aiserver-br-extract 100% 3 251d 4 OK / 4 True
aiserver-br-extract-00002 aiserver-br-extract 2 251d 3 OK / 4 True
aiserver-br-extract-00001 aiserver-br-extract 1 251d 3 OK / 4 True
# 设置当前服务的镜像
> kn service update aiserver-msp-ocr-recog --image <new-image> -n prod
<new-image>: 镜像uri
更新指定服务的流量分配
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
> kn service update -n prod aiserver-msp-ocr-recog --traffic aiserver-msp-ocr-recog-00024=100
==================================================================
Updating Service 'aiserver-msp-ocr-recog' in namespace 'prod':
0.041s The Route is still working to reflect the latest desired specification.
0.092s Ingress has not yet been reconciled.
0.142s Ready to serve.
Service 'aiserver-msp-ocr-recog' with latest revision 'aiserver-msp-ocr-recog-00024' (unchanged) is available at URL:
http://aiserver-msp-ocr-recog.prod.sh
# 切换流量到最新的修订版本上
> kn service update <service> -n prod --traffic @latest=100
==================================================================
Updating Service 'aiserver-vietnam-ocr-recog' in namespace 'prod':
0.047s The Route is still working to reflect the latest desired specification.
0.099s Ready to serve.
Service 'aiserver-vietnam-ocr-recog' with latest revision 'aiserver-vietnam-ocr-recog-00002' (unchanged) is available at URL:
http://aiserver-vietnam-ocr-recog.prod.sh
删除不需要的修订版本
```
删除 prod 下的修订版本: aiserver-peft-tc2-00001
kubectl -n prod delete revisions.serving.knative.dev aiserver-peft-tc2-00001
本文由作者按照
CC BY 4.0
进行授权