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

Commit

Permalink
fix(app) fix request.get problem (#11)
Browse files Browse the repository at this point in the history
* chore(deploy) adjust image version

* fix(app) add retries for request metrics api
  • Loading branch information
deadc authored Oct 9, 2018
1 parent a8118cf commit ab2f897
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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

0 comments on commit ab2f897

Please sign in to comment.