Knative快捷操作命令Kn 怎么用
发表于:2025-02-23 作者:千家信息网编辑
千家信息网最后更新 2025年02月23日,今天就跟大家聊聊有关Knative快捷操作命令Kn 怎么用,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。kn 是 Knative 命令行操作客
千家信息网最后更新 2025年02月23日Knative快捷操作命令Kn 怎么用
今天就跟大家聊聊有关Knative快捷操作命令Kn 怎么用,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
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:73fbdd56yuncs.com/knative-sample/helloworld-go:73fbdd56Creating 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 createdkn 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 changedkn 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 filekn service apply s0 --filename my-svc.yml
查看服务
查询服务列表示例:
kn service listNAME URL LATEST AGE CONDITIONS READY REASONhelloworld-go http://helloworld-go.default.example.com helloworld-go-pyqqz-1 55s 3 OK / 3 True
查询服务详情示例:
kn service describe helloworld-goName: helloworld-goNamespace: defaultAge: 14mURL: http://helloworld-go.default.example.comRevisions: 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 -oyamlapiVersion: serving.knative.dev/v1kind: Servicemetadata: 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-40b32a30597dspec: 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: 100status: 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
更新服务(创建新版本)
使用 update 命令:
kn service update NAME
示例:
$ kn service update helloworld-go --image registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8Updating 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 listNAME SERVICE TRAFFIC TAGS GENERATION AGE CONDITIONS READY REASONhelloworld-go-cvclp-2 helloworld-go 100% 2 40s 4 OK / 4 Truehelloworld-go-pyqqz-1 helloworld-go 1 6m29s 3 OK / 4 True
查看版本详情
$ kn revision describe helloworld-go-cvclp-2Name: helloworld-go-cvclp-2Namespace: defaultAge: 3mImage: registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8 (pinned to 032b80)Env: TARGET=knativeService: helloworld-goConditions: OK TYPE AGE REASON ++ Ready 3m ++ ContainerHealthy 3m ++ ResourcesAvailable 3m I Active 2m NoTraffic
删除版本
$ kn revision delete helloworld-go-pyqqz-1Revision '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
看完上述内容,你们对Knative快捷操作命令Kn 怎么用有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。
服务
命令
管理
示例
事件
版本
内容
详情
资源
支持
更新
查询
二进制
兴趣
可以通过
官方
客户
客户端
文件
方式
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络技术员工作交接表
斗破苍穹手游私服没有服务器列表
校园网服务器防火墙
网络安全讲座观后感800
自己在电脑上怎么建服务器
出现网络安全的问题申论
永州应用软件开发
顺丰数据库产品经理
网络安全技术安全教育的意义
网络安全体系短板
宁波博瀚软件开发有限公司
易康网络技术学业水平考试
特殊软件开发定义
施乐560需要服务器吗
网络安全类型怎么改
社区医院网络安全
镇江网络技术支持联系人
如何登录慧科新闻数据库
互联网科技美学
一站式日志审计服务器
双路一体化行车记录仪软件开发
http服务器框架
信息网络技术好就业吗
oracle数据库创建用户
怀旧服各服务器开放日期
产品信息数据库管理办法
华为武长地区通用软件开发
梦想精灵谷怎么添加服务器
高斯数据库字段注释存在哪里
互联网行业软件开发提成制度