Пример #1
0
    def aws_assume_role(self, aws_role, aws_account_id):
        click.echo('Assuming role %s at %s' % (aws_role, aws_account_id))
        container = Container()
        image = Image()

        AWS_IMAGE = image.get_image('aws')
        envs = {
            'AWS_ROLE': aws_role,
            'AWS_ACCOUNT_ID': aws_account_id,
        }
        envs.update(self.env_auth)

        command = 'assume-role.sh'
        output = container.create(image=AWS_IMAGE,
                                  entrypoint='/bin/bash -c',
                                  command=command,
                                  volumes=['.:/work'],
                                  environment=envs,
                                  tty=False,
                                  stdin_open=False)

        self.env_assume = parse_env('\n'.join(output.splitlines()))
        return self.env_assume
Пример #2
0
import click
from one.one import cli
from one.docker.container import Container
from one.docker.image import Image
from one.utils.environment.aws import EnvironmentAws
from one.utils.config import get_config_value

container = Container()
image = Image()
environment = EnvironmentAws()
AWS_IMAGE = image.get_image('aws')
KUBE_TOOLS_IMAGE = 'dnxsolutions/docker-kube-tools:0.3.2'


def __init__():
    cli.add_command(kubectl)
    cli.add_command(helm)
    cli.add_command(kube_shell)
    cli.add_command(kube_proxy)


def get_kube_config(aws_default_region, cluster_name, envs):
    kubeconfig = get_config_value('plugins.kube.parameters.kubeconfig', '') or '/work/.kube-config'
    command = 'eks --region %s update-kubeconfig --name %s --kubeconfig %s' % (aws_default_region, cluster_name, kubeconfig)
    container.create(
        image=AWS_IMAGE,
        command=command,
        volumes=['.:/work'],
        environment=envs
    )