def retrieve_pods_list(self): """ Retrieve the list of pods for this cluster querying the kubelet API. TODO: the list of pods could be cached with some policy to be decided. """ return retrieve_json(self.pods_list_url)
def retrieve_json_with_optional_auth(self, url): if self.use_kube_auth: return self.retrieve_json_auth(url=url, auth_token=self.get_auth_token(), timeout=self.timeoutSeconds) else: return retrieve_json(url=url, timeout=self.timeoutSeconds)
def get_kube_labels(): global _kube_settings pods = retrieve_json(_kube_settings["labels_url"]) kube_labels = {} for pod in pods["items"]: metadata = pod.get("metadata", {}) name = metadata.get("name") namespace = metadata.get("namespace") labels = metadata.get("labels") if name and labels and namespace: key = "%s/%s" % (namespace, name) kube_labels[key] = ["kube_%s:%s" % (k,v) for k,v in labels.iteritems()] return kube_labels
def retrieve_machine_info(self): """ Retrieve machine info from Cadvisor. """ return retrieve_json(self.machine_info_url)
def _retrieve_metrics(self, url): return retrieve_json(url)
def retrieve_metrics(self): """ Retrieve metrics from Cadvisor. """ return retrieve_json(self.metrics_url)
def get_kube_labels(self): pods = retrieve_json(self.pods_list_url) return self.extract_kube_labels(pods)
def get_kube_labels(self, excluded_keys=None): pods = retrieve_json(self.pods_list_url) return self.extract_kube_labels(pods, excluded_keys=excluded_keys)
def get_kube_labels(): global _kube_settings pods = retrieve_json(_kube_settings["labels_url"]) return extract_kube_labels(pods)
def _retrieve_pods_list(self): kube_settings = get_kube_settings() return retrieve_json(kube_settings["pods_list_url"])
def retrieve_pods_list(self): return retrieve_json(self.pods_list_url)
def retrieve_json_with_optional_auth(self, url): if self.master_use_kube_auth: return self.retrieve_json_auth(url=url, timeout=self.timeoutSeconds) else: return retrieve_json(url=url, timeout=self.timeoutSeconds)