File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
"""
16
- Changes the labels of the "minikube" node. Adds the label "foo" with value
17
- "bar" and will overwrite the "foo" label if it already exists. Removes the
18
- label "baz".
16
+ This example demonstrates the following:
17
+ - Get a list of all the cluster nodes
18
+ - Iterate through each node list item
19
+ - Add or overwirite label "foo" with the value "bar"
20
+ - Remove the label "baz"
21
+ - Return the list of node with updated labels
19
22
"""
20
23
21
- from pprint import pprint
22
-
23
24
from kubernetes import client , config
24
25
25
26
@@ -36,9 +37,14 @@ def main():
36
37
}
37
38
}
38
39
39
- api_response = api_instance .patch_node ("minikube" , body )
40
+ # Listing the cluster nodes
41
+ node_list = api_instance .list_node ()
40
42
41
- pprint (api_response )
43
+ print ("%s\t \t %s" % ("NAME" , "LABELS" ))
44
+ # Patching the node labels
45
+ for node in node_list .items :
46
+ api_response = api_instance .patch_node (node .metadata .name , body )
47
+ print ("%s\t %s" % (node .metadata .name , node .metadata .labels ))
42
48
43
49
44
50
if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments