def _generate_cluster_spec(config, kubernetes=False):
    extra_setup = ''
    dask_cluster = config['dask_cluster']
    metadata = {}
    worker_config = dask_cluster.get('worker_config')
    if worker_config.get('setup'):
        extra_setup = _get_extra_setup(worker_config['setup'])
    if kubernetes:
        name = worker_config.get('image', 'daskdev/dask:latest')
        name = '{}-'.format(re.sub('[\\W_]', '-', name))
        metadata['generateName'] = name
        config_command = CONFIG_TEMPLATE.format(json.dumps(config))
        run_command = 'python -u -m btb_benchmark.kubernetes config.json'
        extra_setup = '\n'.join([extra_setup, config_command, run_command])
    else:
        run_command = WORKER_COMM
        extra_setup = '\n'.join([extra_setup, run_command])
    run_commands = RUN_TEMPLATE.format(extra_setup)
    spec = {'metadata': metadata, 'spec': {'restartPolicy': 'Never', 'containers': [{'args': ['-c', run_commands], 'command': ['tini', '-g', '--', '/bin/sh'], 'image': worker_config.get('image', 'daskdev/dask:latest'), 'name': 'dask-worker', 'resources': worker_config.get('resources', {})}]}}
    return spec
def _generate_cluster_spec(config, kubernetes=False):
    extra_setup = 
    dask_cluster = config['dask_cluster']
    metadata = {}
    worker_config = dask_cluster.get('worker_config')
    if worker_config.get('setup'):
        extra_setup = _get_extra_setup(worker_config['setup'])
    if kubernetes:
        name = worker_config.get('image', 'daskdev/dask:latest')
        name = '{}-'.format(re.sub('[\\W_]', '-', name))
        metadata['generateName'] = name
        config_command = CONFIG_TEMPLATE.format(json.dumps(config))
        run_command = 'python -u -m btb_benchmark.kubernetes config.json'
        extra_setup = '\n'.join([extra_setup, config_command, run_command])
    else:
        run_command = WORKER_COMM
        extra_setup = '\n'.join([extra_setup, run_command])
    run_commands = RUN_TEMPLATE.format(extra_setup)
    spec = {'metadata': metadata, 'spec': {'restartPolicy': 'Never', 'containers': [{'args': ['-c', run_commands], 'command': ['tini', '-g', '--', '/bin/sh'], 'image': worker_config.get('image', 'daskdev/dask:latest'), 'name': 'dask-worker', 'resources': worker_config.get('resources', {})}]}}
    return spec