要运行 CLI 命令,请登录到 NSX-T Container Plug-in容器,然后打开一个终端并运行 nsxcli 命令。

也可以在节点上运行以下命令以显示 CLI 提示符:

  kubectl exec -it <pod name> nsxcli

表 1. 用于 NCP 容器的 CLI 命令

类型

命令

状态

get ncp-nsx status

状态

get ncp-k8s-api-server status

状态

get ncp-watcher <watcher-name>

状态

get ncp-watchers

缓存

get project-cache <project-name>

缓存

get project-caches

缓存

get namespace-cache <namespace-name>

缓存

get namespace-caches

缓存

get pod-cache <pod-name>

缓存

get pod-caches

缓存

get ingress-caches

支持

get support-bundle file <filename>

支持

get ncp-log file <filename>

支持

get node-agent-log file <filename>

支持

get node-agent-log file <filename> <node-name>

表 2. 用于 NSX 节点代理容器的 CLI 命令

类型

命令

状态

get node-agent-hyperbus status

缓存

get app-cache <app-name>

缓存

get app-caches

表 3. 用于 NSX Kube 代理容器的 CLI 命令

类型

命令

状态

get ncp-k8s-api-server status

状态

get kube-proxy-watcher <watcher-name>

状态

get kube-proxy-watchers

状态

dump ovs-flows

用于 NCP 容器的状态命令

  • 显示 NCP 和 NSX Manager 之间的连接状态

    get ncp-nsx status

    示例:

    kubenode> get ncp-nsx status
    NSX Manager status: Healthy
  • 显示 NCP 和 Kubernetes API 服务器之间的连接状态

    get ncp-k8s-api-server status

    示例:

    kubenode> get ncp-k8s-api-server status
    Kubernetes ApiServer status: Healthy
  • 显示输入、命名空间、pod 和服务的监视程序状态

    get ncp-watcher <watcher-name>
    get ncp-watchers

    示例 1:

    kubenode> get ncp-watcher pod
        Average event processing time: 1174 msec (in past 3600-sec window)
        Current watcher started time: Mar 02 2017 10:47:35 PST
        Number of events processed: 1 (in past 3600-sec window)
        Total events processed by current watcher: 1
        Total events processed since watcher thread created: 1
        Total watcher recycle count: 0
        Watcher thread created time: Mar 02 2017 10:47:35 PST
        Watcher thread status: Up

    示例 2:

    kubenode> get ncp-watchers
        pod:
            Average event processing time: 1145 msec (in past 3600-sec window)
            Current watcher started time: Mar 02 2017 10:51:37 PST
            Number of events processed: 1 (in past 3600-sec window)
            Total events processed by current watcher: 1
            Total events processed since watcher thread created: 1
            Total watcher recycle count: 0
            Watcher thread created time: Mar 02 2017 10:51:37 PST
            Watcher thread status: Up
     
        namespace:
            Average event processing time: 68 msec (in past 3600-sec window)
            Current watcher started time: Mar 02 2017 10:51:37 PST
            Number of events processed: 2 (in past 3600-sec window)
            Total events processed by current watcher: 2
            Total events processed since watcher thread created: 2
            Total watcher recycle count: 0
            Watcher thread created time: Mar 02 2017 10:51:37 PST
            Watcher thread status: Up
     
        ingress:
            Average event processing time: 0 msec (in past 3600-sec window)
            Current watcher started time: Mar 02 2017 10:51:37 PST
            Number of events processed: 0 (in past 3600-sec window)
            Total events processed by current watcher: 0
            Total events processed since watcher thread created: 0
            Total watcher recycle count: 0
            Watcher thread created time: Mar 02 2017 10:51:37 PST
            Watcher thread status: Up
     
        service:
            Average event processing time: 3 msec (in past 3600-sec window)
            Current watcher started time: Mar 02 2017 10:51:37 PST
            Number of events processed: 1 (in past 3600-sec window)
            Total events processed by current watcher: 1
            Total events processed since watcher thread created: 1
            Total watcher recycle count: 0
            Watcher thread created time: Mar 02 2017 10:51:37 PST
            Watcher thread status: Up

用于 NCP 容器的缓存命令

  • 获取项目或命名空间的内部缓存

    get project-cache <project-name>
    get project-caches
    get namespace-cache <namespace-name>
    get namespace-caches

    示例 1:

    kubenode> get project-cache default
        isolation:
            is_isolated: False
        logical-router: 8accc9cd-9883-45f6-81b3-0d1fb2583180
        logical-switch:
            id: 9d7da647-27b6-47cf-9cdb-6e4f4d5a356d
            ip_pool_id: 519ff57f-061f-4009-8d92-3e6526e7c17e
            subnet: 10.0.0.0/24
            subnet_id: f75fd64c-c7b0-4b42-9681-fc656ae5e435

    示例 2:

    kubenode> get project-caches
        default:
            isolation:
                is_isolated: False
            logical-router: 8accc9cd-9883-45f6-81b3-0d1fb2583180
            logical-switch:
                id: 9d7da647-27b6-47cf-9cdb-6e4f4d5a356d
                ip_pool_id: 519ff57f-061f-4009-8d92-3e6526e7c17e
                subnet: 10.0.0.0/24
                subnet_id: f75fd64c-c7b0-4b42-9681-fc656ae5e435
     
        kube-system:
            Isolation:
                is_isolated: False
            logical-router: 5032b299-acad-448e-a521-19d272a08c46
            logical-switch:
                id: 85233651-602d-445d-ab10-1c84096cc22a
                ip_pool_id: ab1c5b09-7004-4206-ac56-85d9d94bffa2
                subnet: 10.0.1.0/24
                subnet_id: 73e450af-b4b8-4a61-a6e3-c7ddd15ce751
  • 获取 pod 的内部缓存

    get pod-cache <pod-name>
    get pod-caches

    示例 1:

    kubenode> get pod-cache nsx.default.nginx-rc-uq2lv
        cif_id: 2af9f734-37b1-4072-ba88-abbf935bf3d4
        gateway_ip: 10.0.0.1
        ingress_controller: False
        ip: 10.0.0.2/24
        labels:
            app: nginx        
        mac: 02:50:56:00:08:00
        port_id: d52c833a-f531-4bdf-bfa2-e8a084a8d41b
        vlan: 1

    示例 2:

    kubenode> get pod-caches
        nsx.default.nginx-rc-uq2lv:
            cif_id: 2af9f734-37b1-4072-ba88-abbf935bf3d4
            gateway_ip: 10.0.0.1
            ingress_controller: False
            ip: 10.0.0.2/24
            labels:
                app: nginx
            mac: 02:50:56:00:08:00
            port_id: d52c833a-f531-4bdf-bfa2-e8a084a8d41b
            vlan: 1
  • 获取输入的内部缓存

    get ingress caches

    示例:

    kubenode> get ingress-caches
        nsx.default.nginx-ingress-rc-host-ed3og: 10.192.162.201

用于 NCP 容器的支持命令

  • 在文件存储中保存 NCP 支持包

    支持包包含 pod 中的所有容器的日志文件并具有 tier:nsx-networking 标签。包文件采用 tgz 格式,并保存在 CLI 默认文件存储目录 /var/vmware/nsx/file-store 中。您可以使用 CLI file-store 命令将包文件复制到远程站点中。

    get support-bundle file <filename>

    示例:

    kubenode>get support-bundle file foo
    Bundle file foo created in tgz format
    kubenode>copy file foo url scp://nicira@10.0.0.1:/tmp
  • 在文件存储中保存 NCP 日志

    日志文件以 tgz 格式保存在 CLI 默认文件存储目录 /var/vmware/nsx/file-store 中。您可以使用 CLI file-store 命令将包文件复制到远程站点中。

    get ncp-log file <filename>

    示例:

    kubenode>get ncp-log file foo
    Log file foo created in tgz format
  • 在文件存储中保存节点代理日志

    保存一个节点或所有节点的节点代理日志。日志以 tgz 格式保存在 CLI 默认文件存储目录 /var/vmware/nsx/file-store 中。您可以使用 CLI file-store 命令将包文件复制到远程站点中。

    get node-agent-log file <filename>
    get node-agent-log file <filename> <node-name>

    示例:

    kubenode>get node-agent-log file foo
    Log file foo created in tgz format

用于 NSX 节点代理容器的状态命令

  • 显示节点代理和该节点上的 HyperBus 之间的连接状态。

    get node-agent-hyperbus status

    示例:

    kubenode> get node-agent-hyperbus status
    HyperBus status: Healthy

用于 NSX 节点代理容器的缓存命令

  • 获取应用程序的内部缓存。用户可以检索特定应用程序或所有应用程序的缓存。

    get app-cache <app-name>
    get app-caches

    示例 1:

    kubenode> get app-cache cif104
        ip: 192.168.0.14/32
        mac: 50:01:01:01:01:14
        gateway_ip: 169.254.1.254/16
        vlan_id: 104

    示例 2:

    kubenode> get app-caches
        cif104:
            ip: 192.168.0.14/32
            mac: 50:01:01:01:01:14
            gateway_ip: 169.254.1.254/16
            vlan_id: 104

用于 NSX Kube 代理容器的状态命令

  • 显示 Kube 代理和 Kubernetes API 服务器之间的连接状态

    get ncp-k8s-api-server status

    示例:

    kubenode> get kube-proxy-k8s-api-server status
    Kubernetes ApiServer status: Healthy
  • 显示 Kube 代理监视程序状态

    get kube-proxy-watcher <watcher-name>
    get kube-proxy-watchers

    示例 1:

    kubenode> get kube-proxy-watcher endpoint
        Average event processing time: 15 msec (in past 3600-sec window)
        Current watcher started time: May 01 2017 15:06:24 PDT
        Number of events processed: 90 (in past 3600-sec window)
        Total events processed by current watcher: 90
        Total events processed since watcher thread created: 90
        Total watcher recycle count: 0
        Watcher thread created time: May 01 2017 15:06:24 PDT
        Watcher thread status: Up

    示例 2:

    kubenode> get kube-proxy-watchers
        endpoint:
            Average event processing time: 15 msec (in past 3600-sec window)
            Current watcher started time: May 01 2017 15:06:24 PDT
            Number of events processed: 90 (in past 3600-sec window)
            Total events processed by current watcher: 90
            Total events processed since watcher thread created: 90
            Total watcher recycle count: 0
            Watcher thread created time: May 01 2017 15:06:24 PDT
            Watcher thread status: Up
    
         service:
            Average event processing time: 8 msec (in past 3600-sec window)
            Current watcher started time: May 01 2017 15:06:24 PDT
            Number of events processed: 2 (in past 3600-sec window)
            Total events processed by current watcher: 2
            Total events processed since watcher thread created: 2
            Total watcher recycle count: 0
            Watcher thread created time: May 01 2017 15:06:24 PDT
            Watcher thread status: Up
  • 在节点上转储 OVS 流量

    dump ovs-flows

    示例:

    kubenode> dump ovs-flows
        NXST_FLOW reply (xid=0x4):
        cookie=0x0, duration=8.876s, table=0, n_packets=0, n_bytes=0, idle_age=8, priority=100,ip actions=ct(table=1)
        cookie=0x0, duration=8.898s, table=0, n_packets=0, n_bytes=0, idle_age=8, priority=0 actions=NORMAL
        cookie=0x0, duration=8.759s, table=1, n_packets=0, n_bytes=0, idle_age=8, priority=100,tcp,nw_dst=10.96.0.1,tp_dst=443 actions=mod_tp_dst:443
        cookie=0x0, duration=8.719s, table=1, n_packets=0, n_bytes=0, idle_age=8, priority=100,ip,nw_dst=10.96.0.10 actions=drop
        cookie=0x0, duration=8.819s, table=1, n_packets=0, n_bytes=0, idle_age=8, priority=90,ip,in_port=1 actions=ct(table=2,nat)
        cookie=0x0, duration=8.799s, table=1, n_packets=0, n_bytes=0, idle_age=8, priority=80,ip actions=NORMAL
        cookie=0x0, duration=8.856s, table=2, n_packets=0, n_bytes=0, idle_age=8, actions=NORMAL