Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

fix(app) fix request.get problem #11

Merged
merged 2 commits into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import time
import string

from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry

from prometheus_client import Metric, start_http_server
from prometheus_client.core import REGISTRY

Expand Down Expand Up @@ -33,9 +36,15 @@ def set_token(self):
def kube_metrics(self):
headers = { "Authorization": "Bearer {}".format(self.token) }

session = requests.Session()
retry = Retry(connect=3, backoff_factor=0.1)
adapter = HTTPAdapter(max_retries=retry)
session.mount('http://', adapter)
session.mount('https://', adapter)

payload = {
'nodes': requests.get(self.api_nodes_url, headers=headers, verify=False),
'pods': requests.get(self.api_pods_url, headers=headers, verify=False)
'nodes': session.get(self.api_nodes_url, headers=headers, verify=False),
'pods': session.get(self.api_pods_url, headers=headers, verify=False)
}

return payload
Expand Down
2 changes: 1 addition & 1 deletion deploy/deployment-metrics-server-exporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
serviceAccountName: metrics-server-exporter
containers:
- name: metrics-server-exporter
image: vivareal/metrics-server-exporter:v0.0.2
image: vivareal/metrics-server-exporter:v0.0.3
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8000
Expand Down