安裝並配置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
-