Closed
Description
Link to the issue (please include a link to the specific documentation or example):
https://github.com/kubernetes-client/python/blob/master/examples/node_labels.py
Description of the issue (please include outputs or screenshots if possible):
This example node_labels.py assumes that the cluster should be a minikube single node cluster (where by default, the node name is set to minikube
).
My suggestion here is to make this example more generic, by removing the hard-coded cluster node name. In place of using the hard-coded cluster node name, the script can be modified to do the following:
- retrieve a list of all the cluster nodes (which will also demonstrate how to get cluster nodes using the
list_node()
function) - do the basic label patch action on all node list items
- print a cleaner result, outputting only some specific node object field values (for eg: node
name
& list of updatedlabels
). This will demonstrate the users, how to get specific node object characteristics field's values, for instance,<node_item>.metadata.name
,<node_item>.metadata.labels
, etc.
So, the new output format can be:
NAME LABELS
test_node {'beta.kubernetes.io/arch': 'amd64', 'beta.kubernetes.io/os': 'linux', 'foo': 'bar', 'kubernetes.io/arch': 'amd64', 'kubernetes.io/hostname': '127.0.0.1', 'kubernetes.io/os': 'linux'}