Ejemplo n.º 1
0
from k8sclient.Components import PodBuilder, ServicePort, ServiceBuilder
import re
import time
import sys

register_cluster("yancheng", "~/.kube/config-yancheng")
register_cluster("shanghai", "~/.kube/config-shanghai")

if len(sys.argv) > 1:
    switch_cluster(sys.argv[1])

image = "ihub.helium.io:30100/library/alpine-iperf"
server_args = "iperf -f M -i 1 -m -s"
client_args = r"iperf -f M -t 10 -i 1 -c %s"
namespace = "k8sft"
nodes = sorted(list_ready_nodes())
server_port = ServicePort("serverport", 5001, 5001)
global_server_name = "iperf-server"
glimit = {'cpu': '0', 'memory': '8Gi'}
grequest = {'cpu': '0', 'memory': '0'}
server_service = ServiceBuilder(global_server_name,
                                namespace).add_port(server_port)
reports = {}
report_css = """<style>
table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
}
tr:nth-child(even) {background: #CCC}
tr:nth-child(odd) {background: #FFF}
</style>
Ejemplo n.º 2
0
from k8sclient.keywords import (
    list_ready_nodes,
    cleanup_pods,
    cleanup_services,
    is_pod_running,
)
from k8sclient.Components import (
    ServicePort,
    PodBuilder,
    ServiceBuilder,
)
import time

nodes = list_ready_nodes()
nodes = [n for n in nodes if n.startswith("10.19.137")]
global_service_name = "stress-pod"
namespace = "k8sft"
image = "ihub.helium.io:30100/library/memcached:check"
args = "memcached -m 32 -u root -v"
client_port = ServicePort("clientport", 11211, 11211)
global_service = ServiceBuilder(global_service_name,
                                namespace).add_port(client_port)
counts = [0] * len(nodes)
readys = [True] * len(nodes)
dones = [False] * len(nodes)
node_marks = ["-".join(n.split(".")) for n in nodes]
POD_PER_NODE = 400


def stress_pod():
    total = 0
Ejemplo n.º 3
0
    cleanup_services,
    list_ready_nodes,
    pod_exec,
    wait_for_pod_state,
    RUNNING
)
import re
import json
pattern = re.compile("(\w+)\s+(\d+)m([.\d]+)s")
namespace = "k8sft"
image = "ihub.helium.io:30100/library/memcached:check3"
args = "memcached -m 1028 -u root -v"
client_port = ServicePort("clientport", 11211, 11211)


nodes = [_ for _ in list_ready_nodes() if not _.startswith("10.19.138")][-1::-1]
node_count = len(nodes)
service_per_pod = 40


def deploy_services(nr=0):
    service_id_start = service_per_pod * node_count * nr
    for n in nodes:
        pod_name = "memcached-%d-%s" % (nr, "-".join(n.split(".")), )
        pod = PodBuilder(
            pod_name,
            namespace,
        ).set_node(
            n
        ).add_container(
            pod_name,