Knative 快捷操作命令 Kn 介绍
简介:kn 是 Knative 命令行操作客户端。 通过 kn 可以方便的操作Knative 相关的资源。
kn 是 Knative 命令行操作客户端。 通过 kn 可以方便的操作Knative 相关的资源。
安装 Kn
可以通过官方获取对应的 Kn 二进制
• macOS
• Linux
• Windows
kn 会与 kubectl 使用同样的config 文件,默认使用 $HOME/.kube/config
服务管理
使用 Kn 命令可以执行: list, create, delete, apply, 和 update 操作Knative services.
创建服务
使用 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
查看服务
查询服务列表示例:
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
查询服务详情示例:
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
更新服务(创建新版本)
使用 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 也可进行更新服务
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
删除服务
示例:
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 - 管理服务路由 routes
• kn source - 管理事件源 sources
• kn trigger - 管理事件 triggers
原文链接:https://developer.aliyun.com/article/779806?
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
Knative 快捷操作命令 Kn 介绍相关推荐
- hdfs snapshot 快照的使用场景应用与操作命令的介绍
hdfs snapshot 快照的应用与操作命令的介绍 一:HDFSSnapShot的介绍 Hadoop从2.1.0版开始提供了HDFS SnapShot的功能. 一个snapshot(快照)是一个全 ...
- Knative 基本功能深入剖析:Knative Eventing 之 Sequence 介绍
作者 | 元毅,阿里云容器平台高级开发工程师,负责阿里云容器平台 Knative 相关工作. 导读:在实际的开发中我们经常会遇到将一条数据需要经过多次处理的场景,称为 Pipeline.那么在 Kna ...
- Knative 多容器支持介绍
简介:微服务和容器化带来了将应用程序分解成可重复使用的小型单元的诉求,这些单元通常作为单独的进程运行,或者在单独的容器运行. Kubernetes的Pod模型允许用户创建一个部署单元,该单元可以打包多 ...
- Fiddler工具栏(快捷菜单)介绍
下面对每个工具进行详解的介绍. 1. 一个消息的图标 --点击该按钮可以为所有选定的会话添加备注(对会话进行备注) 2. Replay --向服务器重新发送选中的请求(重放) 使用方法很简单, ...
- PG数据库对象及常用操作命令使用介绍
目录 user: table: index: sequence: view: pg操作命令: 数据对象使用介绍: user: 创建用户: create user test with password ...
- golang mongodb or条件_MongoDB的学习,操作命令详细介绍
mongo shell mongo shell是MongoDB的交互式JavaScript接口. 您可以使用mongo shell查询和更新数据以及执行管理操作. mongo shell作为Mongo ...
- Knative Eventing 之 Sequence 介绍
在处理数据时,往往会涉及到一个数据需要进行多次加工,这时候我们一般是通过Pipeline的方式进行处理.那么在Knative Eventing中是否也能支持对一个事件进行分步骤多次处理? 这个还真有. ...
- 计算机右键功能总结,计算机基础知识:右键快捷菜单功能介绍
一.选择"打开"就会将该文件夹打开 二.选择"共享"就会打开文件夹共享窗口,可以将该文件夹共享出来,供局域网中其他计算机使用本机资源. 三.选择"发送 ...
- Matlab Tips: 高效实用的快捷命令
目录 0. 概要 1. 注释与反注释:Ctrl+R, Ctrl+T 2. 代码格式化:Ctrl+I 3. 代码自动补全 3.1 自动显示函数接口 3.2 Tab键自动补全 4. 代码分块执行 5. 查 ...
最新文章
- CCAI 2020 | 韦峻青:当我们说起自动驾驶
- docker安装mysql远程不能访问,虚拟机中docker安装mysql远程无法访问解决方法
- Asp.net Vnext IValueProvider
- RocketMQ中主从复制
- linq查询不包含某个值的记录_【翻译】C#表达式中的动态查询
- 笔试知识点 网络安全_安全点
- 作者:王玲玲(1978-),女,中国科学院上海天文台高级工程师
- 单个对象和多个对象在内存中的结构图
- Mysql插入锁表情况
- Broker 的 Heap Size 如何设置?
- 浏览器内核选型列表,请大家继续补充
- Windows IOCP模型与Linux EPOLL模块之比较-
- 关于python的论文the philosophy_Philosophy in Python
- 两个组件对不齐(css样式问题)
- 多媒体计算机组装过程,多媒体技术及《计算机组装及维护》课精彩结合.doc
- python调用鼠标驱动_python+selenium 鼠标事件操作方法
- java编写的山寨qq_java 山寨QQ 实现(一)
- 【数学知识】非线性方程求解的二分法以及牛顿迭代法
- lxr-0.3.1 源码阅读 How To.
- 苹果证书导出p12文件
热门文章
- 子弹图(Bullet chart)绘制很难吗?绘制技巧整理送你~~
- 肝!超好懂的 Python 文件读写教程!
- vue 父组建获取子组建方法为获得_Vue父子组件状态同步的最佳方式
- python实现指纹识别毕业论文_指纹识别系统大学本科毕业论文
- 支付二维码php能实现吗_(实用篇)微信支付扫码支付php版
- 机器学习:随机森林算法及其实现
- bootstrap学习(四)表格
- VK Cup 2017 - Round 1
- vue2.0搭建vue手脚架(vue-cli)
- GoldenGate for Java adapter介绍二(代码篇)