使用 Red Hat OpenShift on IBM Cloud (ROKS) 的 oc 命令来查看 Worker Pool 相关信息

在IBM云上的Red Hat OpenShift(ROKS)中,Worker Pool是OpenShift中Worker Node的高级概念之一。ROKS用户可以通过设置Flavor和VLAN等参数来创建Worker Pool,并部署满足工作负载需求的Worker Node。

关于 Worker Pool 的信息可以在 ROKS 的 Portal 画面或者通过 ibmcloud oc worker-pool 命令来确认。参考链接:https://cloud.ibm.com/docs/openshift?topic=openshift-kubernetes-service-cli#worker-pool

$ ibmcloud plugin list
Listing installed plug-ins...

Plugin Name                             Version   Status   Private endpoints supported
container-service[kubernetes-service]   1.0.408            false

$ ibmcloud oc worker-pool help
NAME:
        ibmcloud ks worker-pool - View and modify worker pools for a cluster.
USAGE:
        ibmcloud ks worker-pool command [arguments...] [command options]

COMMANDS:
    create      Add a worker pool to a cluster. No worker nodes are created until zones are added to the worker pool.
    get         List the details of a worker pool.
    label       Set and remove custom Kubernetes labels for all worker nodes in a worker pool.
    ls          List all worker pools in a cluster.
    rebalance   Rebalance a worker pool in a cluster. Rebalancing adds worker nodes so that the worker pool has the same number of nodes per zone that you specified.
    resize      Resize the worker pool to the number of workers per zone that you specify.
    rm          Remove a worker pool from a cluster.
    taint       Set and remove Kubernetes taints for all worker nodes in a worker pool.
    zones       View the zones attached to a worker pool.


Enter 'ibmcloud ks worker-pool help [command]' for more information about a command.

 

一种方法是使用 OpenShift Console 或 oc 命令执行各种 OpenShift 操作。在这里,我们将介绍如何使用 oc 命令检查与 Worker Node 相关的 Worker Pool 的各种信息。

确认工人池相关信息。

Worker Pool 関連情報は、Worker Node の Label ( .metadata.labels ) で確認することが可能です。

$ oc get node -o name
node/90.131.311.131
node/90.131.311.132
node/90.131.311.133
node/90.131.311.136
node/90.131.311.142
node/90.131.311.145
node/90.131.311.155
node/90.131.311.165
node/90.131.311.167
node/90.131.311.169
node/90.131.311.171
node/90.131.311.182
node/90.131.311.183
node/90.131.311.186

$ oc get node/90.131.311.131 -o jsonpath='{.metadata.labels}' | jq -r .
{
  "arch": "amd64",
  "beta.kubernetes.io/arch": "amd64",
  "beta.kubernetes.io/instance-type": "mb4c.20x192.encrypted",
  "beta.kubernetes.io/os": "linux",
  "failure-domain.beta.kubernetes.io/region": "au-syd",
  "failure-domain.beta.kubernetes.io/zone": "syd04",
  "ibm-cloud.kubernetes.io/encrypted-docker-data": "true",
  "ibm-cloud.kubernetes.io/external-ip": "192.168.332.25",
  "ibm-cloud.kubernetes.io/iaas-provider": "softlayer",
  "ibm-cloud.kubernetes.io/internal-ip": "90.131.311.131",
  "ibm-cloud.kubernetes.io/machine-type": "mb4c.20x192.encrypted",
  "ibm-cloud.kubernetes.io/os": "REDHAT_7_64",
  "ibm-cloud.kubernetes.io/region": "au-syd",
  "ibm-cloud.kubernetes.io/sgx-enabled": "false",
  "ibm-cloud.kubernetes.io/worker-id": "kube-c9ecepez0ho14k0xyq10-roks-mypool1-00000dca",
  "ibm-cloud.kubernetes.io/worker-pool-id": "c9ecepez0ho14k0xyq10-9de66b6",
  "ibm-cloud.kubernetes.io/worker-pool-name": "mypool1",
  "ibm-cloud.kubernetes.io/worker-version": "4.6.56_1579_openshift",
  "ibm-cloud.kubernetes.io/zone": "syd04",
  "kubernetes.io/arch": "amd64",
  "kubernetes.io/hostname": "90.131.311.131",
  "kubernetes.io/os": "linux",
  "node-role.kubernetes.io/master": "",
  "node-role.kubernetes.io/worker": "",
  "node.kubernetes.io/instance-type": "mb4c.20x192.encrypted",
  "node.openshift.io/os_id": "rhel",
  "privateVLAN": "0123456",
  "publicVLAN": "9876543",
  "topology.kubernetes.io/region": "au-syd",
  "topology.kubernetes.io/zone": "syd04"
}

顺便提一句,ROKS默认设置的标签无法删除,不支持该操作。请参考此链接:https://cloud.ibm.com/docs/containers?topic=containers-add_workers

请注意:不要删除由mypool2提供的工作池和工作节点标签,因为这些标签对于工作池的正常运行是必需的。只需删除您之前添加的自定义标签即可。

使用 oc 命令显示Worker Pool相关信息

可以使用oc get node命令的-o custom-columns或-o custom-columns-file选项。

$ cat CustomColumnFile.txt
NAME REGION ZONE FLAVOR WORKER_ID WPOOL WPOOL_ID PRIVATE_VLAN PUBLIC_VLAN
.metadata.name .metadata.labels.ibm-cloud\.kubernetes\.io/region .metadata.labels.ibm-cloud\.kubernetes\.io/zone .metadata.labels.ibm-cloud\.kubernetes\.io/machine-type .metadata.labels.ibm-cloud\.kubernetes\.io/worker-id .metadata.labels.ibm-cloud\.kubernetes\.io/worker-pool-name .metadata.labels.ibm-cloud\.kubernetes\.io/worker-pool-id .metadata.labels.privateVLAN .metadata.labels.publicVLAN

$ oc get node -o custom-columns-file=CustomColumnFile.txt --sort-by=".metadata.labels.ibm-cloud\.kubernetes\.io/worker-pool-name"
NAME             REGION   ZONE    FLAVOR                  WORKER_ID                                         WPOOL      WPOOL_ID                       PRIVATE_VLAN   PUBLIC_VLAN
90.131.311.145   au-syd   syd04   mb4c.20x192.encrypted   kube-c9ecepez0ho14k0xyq10-roks-mypool1-00000b53   mypool1    c9ecepez0ho14k0xyq10-9de66b6   0123456        9876543
90.131.311.171   au-syd   syd04   mb4c.20x192.encrypted   kube-c9ecepez0ho14k0xyq10-roks-mypool1-00000c7e   mypool1    c9ecepez0ho14k0xyq10-9de66b6   0123456        9876543
90.131.311.133   au-syd   syd04   mb4c.20x192.encrypted   kube-c9ecepez0ho14k0xyq10-roks-mypool1-00000857   mypool1    c9ecepez0ho14k0xyq10-9de66b6   0123456        9876543
90.131.311.165   au-syd   syd04   mb4c.20x192.encrypted   kube-c9ecepez0ho14k0xyq10-roks-mypool1-00000a81   mypool1    c9ecepez0ho14k0xyq10-9de66b6   0123456        9876543
90.131.311.155   au-syd   syd04   mb4c.20x192.encrypted   kube-c9ecepez0ho14k0xyq10-roks-mypool1-00000e76   mypool1    c9ecepez0ho14k0xyq10-9de66b6   0123456        9876543
90.131.311.131   au-syd   syd04   mb4c.20x192.encrypted   kube-c9ecepez0ho14k0xyq10-roks-mypool1-00000dca   mypool1    c9ecepez0ho14k0xyq10-9de66b6   0123456        9876543
90.131.311.186   au-syd   syd04   mb4c.20x192.encrypted   kube-c9ecepez0ho14k0xyq10-roks-mypool1-000009e8   mypool1    c9ecepez0ho14k0xyq10-9de66b6   0123456        9876543
90.131.311.142   au-syd   syd04   m3c.16x128.encrypted    kube-c9ecepez0ho14k0xyq10-roks-mypool2-000007a4   mypool2    c9ecepez0ho14k0xyq10-30b0e45   0123456        9876543
90.131.311.167   au-syd   syd04   m3c.16x128.encrypted    kube-c9ecepez0ho14k0xyq10-roks-mypool2-0000038a   mypool2    c9ecepez0ho14k0xyq10-30b0e45   0123456        9876543
90.131.311.169   au-syd   syd04   m3c.16x128.encrypted    kube-c9ecepez0ho14k0xyq10-roks-mypool2-000001f5   mypool2    c9ecepez0ho14k0xyq10-30b0e45   0123456        9876543
90.131.311.132   au-syd   syd04   m3c.16x128.encrypted    kube-c9ecepez0ho14k0xyq10-roks-mypool2-000002ad   mypool2    c9ecepez0ho14k0xyq10-30b0e45   0123456        9876543
90.131.311.182   au-syd   syd04   m3c.16x128.encrypted    kube-c9ecepez0ho14k0xyq10-roks-mypool2-00000509   mypool2    c9ecepez0ho14k0xyq10-30b0e45   0123456        9876543
90.131.311.183   au-syd   syd04   m3c.16x128.encrypted    kube-c9ecepez0ho14k0xyq10-roks-mypool2-000004b0   mypool2    c9ecepez0ho14k0xyq10-30b0e45   0123456        9876543
90.131.311.136   au-syd   syd04   m3c.16x128.encrypted    kube-c9ecepez0ho14k0xyq10-roks-mypool2-000006ed   mypool2    c9ecepez0ho14k0xyq10-30b0e45   0123456        9876543

 

广告
将在 10 秒后关闭
bannerAds