[Python] Python - Trying to use monitor kubernetes ready status

Discussão em 'Python' iniciado por Stack, Julho 2, 2025.

  1. Stack

    Stack Membro Participativo

    I'm writing a script and part of it is to monitor the cluster and if all nodes are Ready then continue on with the script. But the issue I'm having is that it hangs and I don't know why:

    from kubernetes import client, config, watch
    import os
    config.load_kube_config()

    v1 = client.CoreV1Api()
    stream = watch.Watch().stream(v1.list_node)


    def monitoring():
    for event in stream:
    node = event['object']
    node_name = node.metadata.name

    # Iterate through node conditions to find the "Ready" status
    ready_status = "Unknown"
    for condition in node.status.conditions:
    if condition.type == "Ready":
    ready_status = condition.status
    break
    print(f"Node: {node_name}, Ready Status: {ready_status}")
    monitoring()


    I see the node status as Ready but it's not breaking out of the loop.

    Continue reading...

Compartilhe esta Página