Skip to content

Commit d3bfc37

Browse files
committed
Add helper function to get CPU architecture of k8s cluster
1 parent aa0d4e0 commit d3bfc37

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

aiopslab/service/kubectl.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,17 @@ def exec_command(self, command: str, input_data=None):
269269
# else:
270270
# return out.stdout.decode("utf-8")
271271

272+
def get_node_architectures(self):
273+
"""Return a set of CPU architectures from all nodes in the cluster."""
274+
architectures = set()
275+
try:
276+
nodes = self.core_v1_api.list_node()
277+
for node in nodes.items:
278+
arch = node.status.node_info.architecture
279+
architectures.add(arch)
280+
except ApiException as e:
281+
print(f"Exception when retrieving node architectures: {e}\n")
282+
return architectures
272283

273284
# Example usage:
274285
if __name__ == "__main__":

0 commit comments

Comments
 (0)