def _guess_apiserver(apiserver_url=None):
 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.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:
  apiserver_url = 'http://127.0.0.1:8080'
 log.debug('Discoverd k8s API server address: {0}'.format(apiserver_url))
 return apiserver_url

def _guess_apiserver ( apiserver_url = None ) : 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 . 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 : apiserver_url = 'http://127.0.0.1:8080' log . debug ( 'Discoverd k8s API server address: {0}' . format ( apiserver_url ) ) return apiserver_url
try to guees the kubemaster url from environ .