Ejemplo n.º 1
0
def run_on_kubernetes(args):
    if args.test:
        cpu_request = '10m'
        memory_request = '200Mi'
    else:
        cpu_request = '500m'
        memory_request = '2Gi'

    context = util.get_cluster_prefix()
    namespace = util.get_current_namespace()
    if len(args.number) == 0:
        # Figure out the nodes based on the names of persistent disks, or just node 0 if none.
        args.number = range(max(1,len(get_persistent_disks(context, namespace))))
    ensure_services_exist()
    util.ensure_secret_exists('rethinkdb-password', 'rethinkdb')
    args.local = False # so tag is for gcloud
    tag = util.get_tag(args, NAME, build)
    t = open(join('conf', '{name}.template.yaml'.format(name=NAME))).read()
    for number in args.number:
        ensure_persistent_disk_exists(context, namespace, number, args.size, args.type)
        with tempfile.NamedTemporaryFile(suffix='.yaml', mode='w') as tmp:
            tmp.write(t.format(image        = tag,
                               number       = number,
                               pd_name      = pd_name(context=context, namespace=namespace, number=number),
                               health_delay = args.health_delay,
                               cpu_request  = cpu_request,
                               memory_request = memory_request,
                               pull_policy  = util.pull_policy(args)))
            tmp.flush()
            util.update_deployment(tmp.name)
Ejemplo n.º 2
0
def run_on_kubernetes(args):
    context = util.get_kube_context()
    namespace = util.get_current_namespace()
    if len(args.number) == 0:
        # Figure out the nodes based on the names of persistent disks, or just node 0 if none.
        args.number = range(
            max(1, len(get_persistent_disks(context, namespace))))
    ensure_services_exist()
    util.ensure_secret_exists('rethinkdb-password', 'rethinkdb')
    args.local = False  # so tag is for gcloud
    tag = util.get_tag(args, NAME, build)
    t = open(join('conf', '{name}.template.yaml'.format(name=NAME))).read()
    for number in args.number:
        ensure_persistent_disk_exists(context, namespace, number, args.size,
                                      args.type)
        with tempfile.NamedTemporaryFile(suffix='.yaml', mode='w') as tmp:
            tmp.write(
                t.format(image=tag,
                         number=number,
                         pd_name=pd_name(context=context,
                                         namespace=namespace,
                                         number=number),
                         health_delay=args.health_delay,
                         pull_policy=util.pull_policy(args)))
            tmp.flush()
            util.update_deployment(tmp.name)
Ejemplo n.º 3
0
def run_on_kubernetes(args):
    context = util.get_cluster_prefix()
    namespace = util.get_current_namespace()
    args.local = False # so tag is for gcloud
    tag = util.get_tag(args, NAME, build)
    # ensure there is a rethinkdb secret, even if blank, so that daemon will start with reduced functionality
    util.ensure_secret_exists('rethinkdb-password', 'rethinkdb')
    t = open('storage-daemon.yaml').read()
    with tempfile.NamedTemporaryFile(suffix='.yaml', mode='w') as tmp:
        tmp.write(t.format(image        = tag,
                           namespace    = util.get_current_namespace(),
                           pull_policy  = util.pull_policy(args)))
        tmp.flush()
        util.update_daemonset(tmp.name)
Ejemplo n.º 4
0
def run_on_kubernetes(args):
    context = util.get_cluster_prefix()
    namespace = util.get_current_namespace()
    tag = util.get_tag(args, NAME, build)
    # ensure there is a rethinkdb secret, even if blank, so that daemon will start with reduced functionality
    util.ensure_secret_exists('rethinkdb-password', 'rethinkdb')
    t = open('storage-daemon.yaml').read()
    with tempfile.NamedTemporaryFile(suffix='.yaml', mode='w') as tmp:
        tmp.write(
            t.format(image=tag,
                     namespace=util.get_current_namespace(),
                     pull_policy=util.pull_policy(args)))
        tmp.flush()
        util.update_daemonset(tmp.name)
Ejemplo n.º 5
0
def run_on_kubernetes(args):
    if args.test:
        rethink_cpu_request = hub_cpu_request = '10m'
        rethink_memory_request = hub_memory_request = '200Mi'
    else:
        hub_cpu_request = '500m'
        hub_memory_request = '1Gi'
        rethink_cpu_request = '500m'
        rethink_memory_request = '2Gi'

    util.ensure_secret_exists('sendgrid-api-key', 'sendgrid')
    util.ensure_secret_exists('zendesk-api-key', 'zendesk')
    args.local = False  # so tag is for gcloud
    if args.replicas is None:
        args.replicas = util.get_desired_replicas(NAME, 2)
    tag = util.get_tag(args, NAME, build)

    opts = {
        'image_hub': tag,
        'replicas': args.replicas,
        'pull_policy': util.pull_policy(args),
        'min_read_seconds': args.gentle,
        'smc_db_hosts': args.database_nodes,
        'smc_db_pool': args.database_pool_size,
        'smc_db_concurrent_warn': args.database_concurrent_warn,
        'hub_cpu_request': hub_cpu_request,
        'hub_memory_request': hub_memory_request,
        'rethink_cpu_request': rethink_cpu_request,
        'rethink_memory_request': rethink_memory_request
    }

    if args.database_nodes == 'localhost':
        from argparse import Namespace
        ns = Namespace(tag=args.rethinkdb_proxy_tag, local=False)
        opts['image_rethinkdb_proxy'] = util.get_tag(ns, 'rethinkdb-proxy',
                                                     build)
        filename = 'smc-hub-rethinkdb-proxy.template.yaml'
    else:
        filename = '{name}.template.yaml'.format(name=NAME)
    t = open(join('conf', filename)).read()
    with tempfile.NamedTemporaryFile(suffix='.yaml', mode='w') as tmp:
        r = t.format(**opts)
        #print(r)
        tmp.write(r)
        tmp.flush()
        util.update_deployment(tmp.name)

    if NAME not in util.get_services():
        util.run(['kubectl', 'expose', 'deployment', NAME])
Ejemplo n.º 6
0
def run_on_kubernetes(args):
    if args.test:
        rethink_cpu_request = hub_cpu_request = '10m'
        rethink_memory_request = hub_memory_request = '200Mi'
    else:
        hub_cpu_request = '300m'
        hub_memory_request = '1Gi'
        rethink_cpu_request = '300m'
        rethink_memory_request = '1Gi'


    util.ensure_secret_exists('sendgrid-api-key', 'sendgrid')
    util.ensure_secret_exists('zendesk-api-key',  'zendesk')
    args.local = False # so tag is for gcloud
    if args.replicas is None:
        args.replicas = util.get_desired_replicas(NAME, 2)
    tag = util.get_tag(args, NAME, build)

    opts = {
        'image_hub'              : tag,
        'replicas'               : args.replicas,
        'pull_policy'            : util.pull_policy(args),
        'min_read_seconds'       : args.gentle,
        'smc_db_hosts'           : args.database_nodes,
        'smc_db_pool'            : args.database_pool_size,
        'smc_db_concurrent_warn' : args.database_concurrent_warn,
        'hub_cpu_request'        : hub_cpu_request,
        'hub_memory_request'     : hub_memory_request,
        'rethink_cpu_request'    : rethink_cpu_request,
        'rethink_memory_request' : rethink_memory_request
    }

    if args.database_nodes == 'localhost':
        from argparse import Namespace
        ns = Namespace(tag=args.rethinkdb_proxy_tag, local=False)
        opts['image_rethinkdb_proxy'] = util.get_tag(ns, 'rethinkdb-proxy', build)
        filename = 'smc-hub-rethinkdb-proxy.template.yaml'
    else:
        filename = '{name}.template.yaml'.format(name=NAME)
    t = open(join('conf', filename)).read()
    with tempfile.NamedTemporaryFile(suffix='.yaml', mode='w') as tmp:
        r = t.format(**opts)
        #print(r)
        tmp.write(r)
        tmp.flush()
        util.update_deployment(tmp.name)

    if NAME not in util.get_services():
        util.run(['kubectl', 'expose', 'deployment', NAME])
Ejemplo n.º 7
0
def run_on_kubernetes(args):
    if args.test or util.get_current_namespace() == 'test':
        rethink_cpu_request = hub_cpu_request = proxy_cpu_request = '10m'
        rethink_memory_request = hub_memory_request = proxy_memory_request = '200Mi'
    else:
        hub_cpu_request = '500m'
        hub_memory_request = '1Gi'
        proxy_cpu_request = '200m'
        proxy_memory_request = '500Mi'
        rethink_cpu_request = '500m'
        rethink_memory_request = '2Gi'

    util.ensure_secret_exists('sendgrid-api-key', 'sendgrid')
    util.ensure_secret_exists('zendesk-api-key', 'zendesk')
    if args.replicas is None:
        args.replicas = util.get_desired_replicas(NAME, 2)

    opts = {
        'replicas': args.replicas,
        'pull_policy': util.pull_policy(args),
        'min_read_seconds': args.gentle,
        'smc_db_pool': args.database_pool_size,
        'smc_db_concurrent_warn': args.database_concurrent_warn,
        'hub_cpu_request': hub_cpu_request,
        'hub_memory_request': hub_memory_request,
        'proxy_cpu_request': proxy_cpu_request,
        'proxy_memory_request': proxy_memory_request,
        'rethink_cpu_request': rethink_cpu_request,
        'rethink_memory_request': rethink_memory_request
    }
    for image in IMAGES:
        opts['image_{image}'.format(image=image)] = get_tag(args, image)

    from argparse import Namespace
    ns = Namespace(tag=args.rethinkdb_proxy_tag, local=False)
    opts['image_rethinkdb_proxy'] = util.get_tag(ns, 'rethinkdb-proxy')
    filename = 'hub.template.yaml'
    t = open(join('conf', filename)).read()
    with tempfile.NamedTemporaryFile(suffix='.yaml', mode='w') as tmp:
        r = t.format(**opts)
        #print(r)
        tmp.write(r)
        tmp.flush()
        util.update_deployment(tmp.name)

    if NAME not in util.get_services():
        util.run(['kubectl', 'expose', 'deployment', NAME])