安装并配置VNodectl命令行工具后,您可以使用VNodectl来管理VNode、插件等。本文列举了VNodectl常用命令供您参考。
vnode命令均支持添加
--dry进行客户端校验。执行vnode命令的过程中,如果遇到API版本兼容的错误,请添加
--kubernetes-version明确指定集群的Kubernetes版本。
管理VNode
使用下述命令管理VNode时,需确保~/.vnode/config文件存在且配置正确。
create
create命令用于创建VNode。
-
命令格式
vnode create [--vswitch-id] [--security-group-id] [--custom-resources] [--cluster-dns] [--cluster-domain] -
参数说明
参数
说明
示例
--vswitch-id
VNode所属的交换机ID。
--vswitch-id vsw-7xv2yk45qp5etidgf****
--security-group-id
VNode所属的安全组ID。
--security-group-id sg-7xv5tcch4kjdr65t****
--custom-resources
VNode支持的自定义资源。如果ECI Pod的request中声明了相应的自定义资源,则该Pod会被调度到VNode。
格式为
资源名称=资源数量,多个资源之间使用半角逗号间隔。--custom-resources example1.com=10000,example2.com=20000
--cluster-dns
DNS服务器的IP地址。如果ECI Pod中设置了
dnsPolicy=ClusterFirst,则使用该配置值为容器提供DNS服务。支持配置多个IP地址,多个IP地址之间使用半角逗号间隔。
--cluster-dns 192.168.XX.XX
--cluster-domain
集群的域名。配置后,除了主机的搜索域外,Kubelet会配置所有容器来搜索该域名。
--cluster-domain example.com
-
使用示例
-
示例一:不添加参数创建VNode
[root@inode test001 ~]# vnode create {"RequestId":"12B984BB-D3FB-53D2-8326-9A2E9EF7EF46","VirtualNodeId":"vnd-7xv6g0gp3ok6xxx"} -
示例二:配置自定义资源(customResources)
[root@xxx test001 ~]# vnode create --custom-resources example1.com=10000,example2.com=20000 {"RequestId":"98965B78-4F19-5DA4-BAAA-E6461BF7FF67","VirtualNodeId":"vnd-7xv1zedhxpxxx"}创建完成后,您可以通过
kubectl describe node命令查看节点详情,在Capacity和Allocatable中可以看到配置的自定义资源。Capacity: alibabacloud.com/vfuse: 6k cpu: 100k ephemeral-storage: 40000Gi example1.com: 10k example2.com: 20k memory: 1000Ti nvidia.com/gpu: 1k pods: 2k Allocatable: alibabacloud.com/vfuse: 6k cpu: 100k ephemeral-storage: 40000Gi example1.com: 10k example2.com: 20k memory: 1000Ti nvidia.com/gpu: 1k pods: 2k -
示例三:配置clusterDNS和clusterDomain
[root@le-test001 ~]# vnode create --cluster-dns 192.168.0.1 --cluster-domain example.com {"RequestId":"1FCB1308-7C96-5FF2-A7BB-202F69D1961C","VirtualNodeId":"vnd-7xv4qqroc5f***4"}创建完成后,对于调度到该VNode的ECI Pod,通过
kubectl describe pod命令查看Pod详情,在annotations中可以查看clusterDNS和clusterDomain。[root@xxx e-test001 ~]# kubectl describe pod test-5748b8cfb6-xgmp7 Name: test-5748b8cfb6-xgmp7 Namespace: default Priority: 0 Node: cn-guangzhou.vnd-7xv4qqrxxx4/192.168.xxx Start Time: Mon, 27 Mar 2023 17:27:06 +0800 Labels: alibabacloud.com/eci=true app=nginx pod-template-hash=5748b8cfb6 Annotations: k8s.aliyun.com/cluster-dns: 192.168.0.1 k8s.aliyun.com/cluster-domain: example.com k8s.aliyun.com/eci-created-by-template: true k8s.aliyun.com/eci-extra-ephemeral-storage: 62Gi k8s.aliyun.com/eci-instance-cpu: 2.0 k8s.aliyun.com/eci-instance-id: eci-7xv4qqrocxxx k8s.aliyun.com/eci-instance-mem: 4.0 k8s.aliyun.com/eci-instance-spec: 2.0-4.0Gi k8s.aliyun.com/eci-instance-zone: cn-guangzhou-a k8s.aliyun.com/eci-matched-image-cache: imc-7xv80t0k3gxxx
-
list
list命令用于查询VNode状态。
-
命令格式
vnode list -
使用示例
[root@vnode test001 ~]# vnode list VNODE ID VNODE NAME CREATED STATUS SCHEDULABLE ZONES vnd-7xv6g0gp3okxxx vnode-cn-guangzhou-a-7xv6g0xxx About a minute ago Ready cn-guangzhou-a vnd-7xvetkyase7xxx vnode-cn-guangzhou-a-7xvetkxxx 49 minutes ago Ready cn-guangzhou-a [root@vnode test001 ~]#
describe
describe命令用于查看某一VNode的详细信息。
-
命令格式
vnode describe <vnode id> -
使用示例
[ xxx@vnode-test001 ~]# vnode describe vnd-7xv6g0gp3xxx VNodeId: vnd-7xv6g0gp3ok69xxx VNodeName: vnode-cn-guangzhou-a-7xv6g0gp3xxx ClusterId: RegionId : cn-guangzhou ResourceGroupId: rg-acfm4ia6xxx SecurityGroupId: sg-7xv5tcchxxx VpcId: vpc-7xvuaoizvudf366bhxxx VSwitchId: vsw-7xv4hi6ioxpw3xxx Status: Ready CreationTime:2022-12-23T06:44:52Z IntranetIp: 192.168.xxx.54 InternetIp: Cpu : Memeory: Tags : []Events: Type Reason Agent Message ----- ----- ----- ----- Normal StartingHeartBeat 2 minutes ago birth cry Warning HeartBeatToECIServiceFailed 2 minutes ago fail to connect eci-service Normal CreateEciForVnode 2 minutes ago [eci.virtualnode]Create Eci eci-7xv6g0gp3xxx for Vnode Normal StartingVKubelet 2 minutes ago Starting VKubelet.
update
update命令用于更新指定的VNode配置。支持更新交换机、安全组、customResources、clusterDNS和clusterDomain。
-
命令格式
vnode update <vnode id> [--vswitch-id] [--security-group-id] [--custom-resources] [--cluster-dns] [--cluster-domain] -
参数说明
重要update命令更新VNode配置为全量更新,传入的参数值会覆盖原有参数值,例如原有VNode已配置
--custom-resources example1.com=10000,此时如果想要增加自定义资源example2.com,数量为10000,需传入--custom-resources example1.com=10000,example2.com=10000。参数
说明
示例
--vswitch-id
VNode所属的交换机ID。
--vswitch-id vsw-7xv2yk45qp5etidgf****
--security-group-id
VNode所属的安全组ID。
--security-group-id sg-7xv5tcch4kjdr65t****
--custom-resources
VNode支持的自定义资源。如果ECI Pod的request中声明了相应的自定义资源,则该Pod会被调度到VNode。
格式为
资源名称=资源数量,多个资源之间使用半角逗号间隔。--custom-resources example1.com=10000,example2.com=20000
--cluster-dns
DNS服务器的IP地址。如果ECI Pod中设置了
dnsPolicy=ClusterFirst,则使用该配置值为容器提供DNS服务。支持配置多个IP地址,多个IP地址之间使用半角逗号间隔。
--cluster-dns 192.168.XX.XX
--cluster-domain
集群的域名。配置后,除了主机的搜索域外,Kubelet会配置所有容器来搜索该域名。
--cluster-domain example.com
-
使用示例
[xxx de-test001 ~]# vnode update vnd-7xv1zedhx xxx r --cluster-domain example.com {"RequestId":"DA86B896-3A05-5A0C-A9D2-A1D433C85035"}
delete
delete命令用于删除指定的VNode。删除前,需确保VNode上没有ECI实例。
-
命令格式
vnode delete <vnode id> -
使用示例
[r xxx est001 ~]# vnode delete vnd-7xv6g0gp3o are you sure to delete vnd-7xv6g0gp3ol xxx d ?(y/n)y {"RequestId":"7B7E8276-772A-5229-B2D7-B3DD36A66432"}
管理组件
除管理VNode外,VNodectl还可以管理eci-profile和vnode-approver组件。
addon list
addon list命令用于列出可用插件。
-
命令格式
vnode addon list --kubeconfig /path/to/kubeconfig -
使用示例
[root@xxx test001 ~]# vnode addon list --kubeconfig ~/.kube/config ADDON NAME | STATUS | MAINTAINER | REPOSITORY -----------------+------------+--------------+------------------------------------------------------ eci-profile | enabled ✅ | ECI Group | https://github.com/aliyuneci/eci-profile.git vnode-approver | disabled | ECI Group | https://github.com/aliyuneci/vnode-approver.git
addon enable
addon enable命令用于加载插件。
-
命令格式
vnode addon enable <plug-in name> --kubeconfig /path/to/kubeconfig -
命令示例
[root@xxx ~]# vnode addon list ADDON NAME | STATUS | MAINTAINER | REPOSITORY eci-profile | disabled | ECI Group | https://github.com/aliyuneci/eci-profile.git vnode-approver | disabled | ECI Group | https://github.com/aliyuneci/vnode-approver.git [root@xxx ~]# vnode addon enable eci-profile --kubeconfig ~/.kube/config clusterrole.rbac.authorization.k8s.io/eci-profile created clusterrolebinding.rbac.authorization.k8s.io/eci-profile created customresourcedefinition.apiextensions.k8s.io/selectors.eci.aliyun.com created service/eci-profile created serviceaccount/eci-profile created deployment.apps/eci-profile created [root@xxx ~]# vnode addon list ADDON NAME | STATUS | MAINTAINER | REPOSITORY eci-profile | enabled ✅ | ECI Group | https://github.com/aliyuneci/eci-profile.git vnode-approver | disabled | ECI Group | https://github.com/aliyuneci/vnode-approver.git
addon disable
addon disable命令用于卸载插件。
-
命令格式
vnode addon disable <plug-in name> --kubeconfig /path/to/kubeconfig -
使用示例
[root@xxx c001 ~]# vnode addon list ADDON NAME | STATUS | MAINTAINER | REPOSITORY eci-profile | enabled ✓ | ECI Group | https://github.com/aliyuneci/eci-profile.git vnode-approver | disabled | ECI Group | https://github.com/aliyuneci/vnode-approver.git [root@xxx 01 ~]# vnode addon disable eci-profile --kubeconfig ~/.kube/config clusterrole.rbac.authorization.k8s.io "eci-profile" deleted clusterrolebinding.rbac.authorization.k8s.io "eci-profile" deleted customresourcedefinition.apiextensions.k8s.io "selectors.eci.aliyun.com" deleted Error from server (NotFound): error when deleting "/root/.vnode/addon/eci-profile/eci-profile-cus... service "eci-profile" deleted serviceaccount "eci-profile" deleted deployment.apps "eci-profile" deleted [root@xxx 1 ~]# vnode addon list ADDON NAME | STATUS | MAINTAINER | REPOSITORY eci-profile | disabled | ECI Group | https://github.com/aliyuneci/eci-profile.git vnode-approver | disabled | ECI Group | https://github.com/aliyuneci/vnode-approver.git
清理集群配置
cluster clean
cluster clean命令用于清理集群配置。如果后续不再使用VNode,可执行该命令清理。
-
命令格式
vnode cluster clean --kubeconfig <kubeconfig路径> [--bootstrap] -
使用示例
-
之前使用普通方式配置集群
vnode cluster clean --kubeconfig /path/to/kubeconfig -
之前TLS Bootstrap方式配置集群
vnode cluster clean --kubeconfig /path/to/kubeconfig --bootstrap
-