def create_kubeconfig(kubeconfig, server, ca, key=None, certificate=None, user='ubuntu', context='juju-context', cluster='juju-cluster', password=None, token=None):
    'Create a configuration for Kubernetes based on path using the supplied\n    arguments for values of the Kubernetes server, CA, key, certificate, user\n    context and cluster.'
    if ((not key) and (not certificate) and (not password) and (not token)):
        raise ValueError('Missing authentication mechanism.')
    if (token and password):
        raise ValueError('Token and Password are mutually exclusive.')
    cmd = 'kubectl config --kubeconfig={0} set-cluster {1} --server={2} --certificate-authority={3} --embed-certs=true'
    check_call(split(cmd.format(kubeconfig, cluster, server, ca)))
    cmd = 'kubectl config --kubeconfig={0} unset users'
    check_call(split(cmd.format(kubeconfig)))
    cmd = 'kubectl config --kubeconfig={0} set-credentials {1} '.format(kubeconfig, user)
    if (key and certificate):
        cmd = '{0} --client-key={1} --client-certificate={2} --embed-certs=true'.format(cmd, key, certificate)
    if password:
        cmd = '{0} --username={1} --password={2}'.format(cmd, user, password)
    if token:
        cmd = '{0} --token={1}'.format(cmd, token)
    check_call(split(cmd))
    cmd = 'kubectl config --kubeconfig={0} set-context {1} --cluster={2} --user={3}'
    check_call(split(cmd.format(kubeconfig, context, cluster, user)))
    cmd = 'kubectl config --kubeconfig={0} use-context {1}'
    check_call(split(cmd.format(kubeconfig, context)))
Create a configuration for Kubernetes based on path using the supplied
arguments for values of the Kubernetes server, CA, key, certificate, user
context and cluster.
def create_kubeconfig(kubeconfig, server, ca, key=None, certificate=None, user='ubuntu', context='juju-context', cluster='juju-cluster', password=None, token=None):
    'Create a configuration for Kubernetes based on path using the supplied\n    arguments for values of the Kubernetes server, CA, key, certificate, user\n    context and cluster.'
    if ((not key) and (not certificate) and (not password) and (not token)):
        raise ValueError('Missing authentication mechanism.')
    if (token and password):
        raise ValueError('Token and Password are mutually exclusive.')
    cmd = 'kubectl config --kubeconfig={0} set-cluster {1} --server={2} --certificate-authority={3} --embed-certs=true'
    check_call(split(cmd.format(kubeconfig, cluster, server, ca)))
    cmd = 'kubectl config --kubeconfig={0} unset users'
    check_call(split(cmd.format(kubeconfig)))
    cmd = 'kubectl config --kubeconfig={0} set-credentials {1} '.format(kubeconfig, user)
    if (key and certificate):
        cmd = '{0} --client-key={1} --client-certificate={2} --embed-certs=true'.format(cmd, key, certificate)
    if password:
        cmd = '{0} --username={1} --password={2}'.format(cmd, user, password)
    if token:
        cmd = '{0} --token={1}'.format(cmd, token)
    check_call(split(cmd))
    cmd = 'kubectl config --kubeconfig={0} set-context {1} --cluster={2} --user={3}'
    check_call(split(cmd.format(kubeconfig, context, cluster, user)))
    cmd = 'kubectl config --kubeconfig={0} use-context {1}'
    check_call(split(cmd.format(kubeconfig, context)))