コード例 #1
0
ファイル: create.py プロジェクト: retr0h/kindly
def create(ctx):
    '''Create a new cluster. '''

    args = ctx.obj.get('args')
    command_args = {}

    c = config.Config(args, command_args)
    s = spec.DeploymentSpec(c.kindly_file)
    d = driver.Kind(c, s)
    p = packager.Helm(c, s)
    o = orchestrator.Kubectl(c, s)

    cluster_name = s.cluster_name
    if d.exists():
        msg = f"Cluster '{cluster_name}' already exists"
        util.abort_with_message(msg)

    with halo.Halo(
            text=f"Creating cluster '{cluster_name}'",
            spinner='dots',
            enabled=c.spinner,
    ) as spinner:
        d.create()
        spinner.succeed()

    if s.template_spec_contains('image'):
        with halo.Halo(
                text=f"Loading image '{s.image}'",
                spinner='dots',
                enabled=c.spinner,
        ) as spinner:
            d.load_image()
            spinner.succeed()

    if s.template_spec_contains('packager'):
        with halo.Halo(
                text=f"Create package namespace '{s.packager_namespace}'",
                spinner='dots',
                enabled=c.spinner,
        ) as spinner:
            o.create_namespace()
            spinner.succeed()

        with halo.Halo(
                text=f"Install package '{s.packager_chart}'",
                spinner='dots',
                enabled=c.spinner,
        ) as spinner:
            p.install()
            spinner.succeed()

    if s.template_spec_contains('configs'):
        with halo.Halo(
                text=
                f"Create objects from yaml definitions in '{s.configs_path}'",
                spinner='dots',
                enabled=c.spinner,
        ) as spinner:
            o.create_objects()
            spinner.succeed()
コード例 #2
0
ファイル: get.py プロジェクト: retr0h/kindly
def get(ctx):
    '''Get all Kind clusters. '''

    args = ctx.obj.get('args')
    command_args = {}

    c = config.Config(args, command_args)
    s = spec.DeploymentSpec(c.kindly_file)
    d = driver.Kind(c, s)

    data = {'clusters': d.get()}
    click.echo(util.safe_dump(data))
コード例 #3
0
ファイル: apply.py プロジェクト: retr0h/kindly
def apply(ctx):
    '''Apply configs to an existing cluster. '''

    args = ctx.obj.get('args')
    command_args = {}

    c = config.Config(args, command_args)
    s = spec.DeploymentSpec(c.kindly_file)
    d = driver.Kind(c, s)
    p = packager.Helm(c, s)
    o = orchestrator.Kubectl(c, s)

    if not d.exists():
        msg = (f"Cluster '{s.cluster_name}' does not exist.  "
               "Please execute create subcommand.")
        util.abort_with_message(msg)

    with halo.Halo(
            text="Setting orchestrator's context",
            spinner='dots',
            enabled=c.spinner,
    ) as spinner:
        o.set_context()
        spinner.succeed()

    if s.template_spec_contains('image'):
        with halo.Halo(
                text=f"Loading image '{s.image}'",
                spinner='dots',
                enabled=c.spinner,
        ) as spinner:
            d.load_image()
            spinner.succeed()

    if s.template_spec_contains('packager'):
        with halo.Halo(
                text=f"Upgrade package '{s.packager_chart}'",
                spinner='dots',
                enabled=c.spinner,
        ) as spinner:
            p.upgrade()
            spinner.succeed()

    if s.template_spec_contains('configs'):
        with halo.Halo(
                text=f"Apply updated configs in '{s.configs_path}'",
                spinner='dots',
                enabled=c.spinner,
        ) as spinner:
            o.update_objects()
            spinner.succeed()
コード例 #4
0
def delete(ctx):
    '''Delete an existing cluster. '''

    args = ctx.obj.get('args')
    command_args = {}

    c = config.Config(args, command_args)
    s = spec.DeploymentSpec(c.kindly_file)
    d = driver.Kind(c, s)

    with halo.Halo(text='Deleting cluster', spinner='dots',
                   enabled=c.spinner) as spinner:
        d.delete()
        spinner.succeed()
コード例 #5
0
def spec_instance(config_instance):
    return spec.DeploymentSpec(config_instance.kindly_file)