예제 #1
0
def _wait_for_pod_ready(nodes, timeout=420):
    ready = [False for _ in nodes]
    start = time.time()
    while True:
        if all(ready):
            break
        for i, n in enumerate(nodes):
            if ready[i]:
                continue
            node_mark = _get_node_mark(n)
            pod_1 = ("pod-%s-%d" % (node_mark, 1)) + uid
            pod_2 = ("pod-%s-%d" % (node_mark, 0)) + uid
            ready[i] = (is_pod_running(namespace, pod_1)
                        and is_pod_running(namespace, pod_2))
            if ready[i]:
                print pod_1, pod_2, "is Running."
        if time.time() - start > timeout:
            break
        time.sleep(3)
    return [nodes[i] for i, r in enumerate(ready) if r]
예제 #2
0
def _wait_for_pod_ready(timeout=420):
    ready = [False for _ in nodes]
    start = time.time()
    while True:
        if all(ready):
            break
        for i, n in enumerate(nodes):
            if ready[i]:
                continue
            pod_name = pod_names[n]
            ready[i] = is_pod_running(namespace, pod_name)
            if ready[i]:
                print pod_name, "is Running."
        if time.time() - start > timeout:
            break
        time.sleep(3)
    return [nodes[i] for i, r in enumerate(ready) if r]
예제 #3
0
def stress_pod():
    total = 0
    start = time.time()
    while not all(dones):
        # deploy ready nodes
        for i, n in enumerate(nodes):
            pod_id = counts[i]
            if dones[i]:
                continue
            pod_name = ("pod-%s-%d" % (node_marks[i], pod_id))
            if readys[i]:
                # create a new pod
                PodBuilder(
                    pod_name,
                    namespace,
                ).set_node(n).add_container(
                    pod_name,
                    image=image,
                    args=args,
                    ports=[client_port],
                    requests={
                        'cpu': '0',
                        "memory": '0'
                    },
                    limits={
                        'cpu': '1',
                        "memory": '32Mi'
                    }).attache_service(global_service).deploy()
                readys[i] = False
                # print "creating", pod_name
            else:
                # check for current pod running
                readys[i] = is_pod_running(namespace, pod_name)
                if readys[i]:
                    total += 1
                    counts[i] += 1
                if counts[i] >= POD_PER_NODE:
                    print "It took %ds to deploy %d pod on %s" % (
                        int(time.time() - start), POD_PER_NODE, n)
                    # print n, "is done~!", "total", total
                    dones[i] = True
        time.sleep(3)
    print "it took", time.time() - start, "s"
예제 #4
0
def _check_pod_running(n):
    node_mark = "-".join(n.split("."))
    pod_1 = ("pod-%s-%d" % (node_mark, 0)) + args.uid
    pod_2 = ("pod-%s-%d" % (node_mark, 1)) + args.uid
    return is_pod_running(args.namespace, pod_1) and is_pod_running(
        args.namespace, pod_2)