Ejemplo n.º 1
0
def main(min_replica=1,
         max_replica=2,
         aws_region='vir',
         runtime_env='dev',
         dry_run=True,
         debug=True):
    '''
    Main function
    '''
    service_name = 'sample_application'
    namespace = 'alexrhino'
    if debug:
        logging.basicConfig(level=logging.DEBUG)
        logging.info("DEBUG ON")
    else:
        logging.basicConfig(level=logging.INFO)
        logging.info("DEBUG OFF")
    if int(max_replica) >= int(min_replica) and int(min_replica) > 0:
        cm = ClusterManager(runtime_env, aws_region)
        my_service = SampleApplication('sample_application', 'alexrhino')
        manifest_spec = my_service.load_general_manifest(
            'hpa', runtime_env, aws_region)
        manifest_spec['spec']['maxReplicas'] = max_replica
        manifest_spec['spec']['minReplicas'] = min_replica
        cm.deploy_manifest(manifest_spec, dry_run)
    else:
        logging.error('Wrong replica range, from %s to %s, please check',
                      min_replica, max_replica)
Ejemplo n.º 2
0
def main(image_tag,
         aws_region='vir',
         runtime_env='dev',
         dry_run=True,
         debug=True):
    '''
    Main function
    '''
    service_name = 'sample_application'
    namespace = 'alexrhino'
    if debug:
        logging.basicConfig(level=logging.DEBUG)
        logging.info("DEBUG ON")
    else:
        logging.basicConfig(level=logging.INFO)
        logging.info("DEBUG OFF")
    cm = ClusterManager(runtime_env, aws_region)
    my_service = SampleApplication('sample_application', 'alexrhino')
    image_url = my_service.get_image_url(image_tag)
    extra_vars = {'image_url': image_url}
    manifest_spec = my_service.load_general_manifest('deploy',
                                                     runtime_env,
                                                     aws_region,
                                                     extra_vars=extra_vars)
    if not dry_run:
        my_service.update_s3_image_url(runtime_env, aws_region, image_tag)
    cm.deploy_manifest(manifest_spec, dry_run)
Ejemplo n.º 3
0
def main(service_name='sample_application',
         aws_region='tyo',
         runtime_env='test',
         dry_run=True,
         namespace='alexrhino',
         debug=True,
         extra_vars='',
         manifest_type='configmap'):
    '''
    Main function
    '''
    if debug:
        logging.basicConfig(level=logging.DEBUG)
        logging.info("DEBUG ON")
    else:
        logging.basicConfig(level=logging.INFO)
        logging.info("DEBUG OFF")
    cluster_controller = ClusterManager(runtime_env, aws_region)
    general_service = MicroService(service_name, namespace)
    if manifest_type == 'configmap':
        manifests = general_service.get_configmap_manifests(
            runtime_env, aws_region)
    else:
        manifest = general_service.load_general_manifest(
            manifest_type, runtime_env, aws_region, extra_vars)
        manifests = [manifest]
    for manifest in manifests:
        cluster_controller.deploy_manifest(manifest, dry_run)
Ejemplo n.º 4
0
def deploy_all_regions(runtime_env,
                       namespace,
                       service_name,
                       manifest_type,
                       dry_run=True,
                       debug=True):
    '''
    Main function
    '''
    set_log_level(debug)
    all_changed = []
    runtime_envs = config.get_runtime_envs(runtime_env)
    if service_name == 'sample_application':
        my_service = SampleApplication(service_name, namespace)
    else:
        my_service = MicroService(service_name, namespace)
    for env in runtime_envs:
        for region in config.get_regions(env, 'all'):
            cm = ClusterManager(env, region)
            if config.has_manifest(env, region, namespace, service_name,
                                   manifest_type):
                manifest_spec = my_service.load_general_manifest(
                    manifest_type, runtime_env, region)
                cm.deploy_manifest(manifest_spec, dry_run)