def _guess_apiserver(apiserver_url=None):
    '''Try to guees the kubemaster url from environ,
    then from `/etc/kubernetes/config` file
    '''
    default_config = "/etc/kubernetes/config"
    if apiserver_url is not None:
        return apiserver_url
    if "KUBERNETES_MASTER" in os.environ:
        apiserver_url = os.environ.get("KUBERNETES_MASTER")
    elif __salt__['config.get']('k8s:master'):
        apiserver_url = __salt__['config.get']('k8s:master')
    elif os.path.exists(default_config) or __salt__['config.get']('k8s:config', ""):
        config = __salt__['config.get']('k8s:config', default_config)
        kubeapi_regex = re.compile("""KUBE_MASTER=['"]--master=(.*)['"]""",
                                   re.MULTILINE)
        with salt.utils.files.fopen(config) as fh_k8s:
            for line in fh_k8s.readlines():
                match_line = kubeapi_regex.match(line)
            if match_line:
                apiserver_url = match_line.group(1)
    else:
        # we failed to discover, lets use k8s default address
        apiserver_url = "http://127.0.0.1:8080"
    log.debug("Discoverd k8s API server address: %s", apiserver_url)
    return apiserver_url