Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
Allow customization of NODE_LABEL_SPOT_VALUE to be different than `…
Browse files Browse the repository at this point in the history
…true` (#164)
  • Loading branch information
gavinbunney authored Apr 30, 2020
1 parent 1acc60b commit b48b59a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ You can run ``docker run --rm hjacobs/kube-resource-report:20.4.4 --help`` to fi
Besides this, you can also pass environment variables:

- ``NODE_LABEL_SPOT`` (default: ``"aws.amazon.com/spot"``)
- ``NODE_LABEL_SPOT_VALUE`` (default: ``"true"``)
- ``NODE_LABEL_PREEMPTIBLE`` (default: ``cloud.google.com/gke-preemptible``)
- ``NODE_LABEL_ROLE`` (default: ``"kubernetes.io/role"``)
- ``NODE_LABEL_REGION`` (default: ``"failure-domain.beta.kubernetes.io/region"``)
Expand Down
3 changes: 2 additions & 1 deletion kube_resource_report/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from kube_resource_report import pricing

NODE_LABEL_SPOT = os.environ.get("NODE_LABEL_SPOT", "aws.amazon.com/spot")
NODE_LABEL_SPOT_VALUE = os.environ.get("NODE_LABEL_SPOT_VALUE", "true")
NODE_LABEL_PREEMPTIBLE = os.environ.get(
"NODE_LABEL_PREEMPTIBLE", "cloud.google.com/gke-preemptible"
)
Expand Down Expand Up @@ -161,7 +162,7 @@ def map_node(_node: Node):
role = _node.labels.get(NODE_LABEL_ROLE) or "worker"
region = _node.labels.get(NODE_LABEL_REGION, "unknown")
instance_type = _node.labels.get(NODE_LABEL_INSTANCE_TYPE, "unknown")
is_spot = _node.labels.get(NODE_LABEL_SPOT) == "true"
is_spot = _node.labels.get(NODE_LABEL_SPOT) == NODE_LABEL_SPOT_VALUE
is_preemptible = _node.labels.get(NODE_LABEL_PREEMPTIBLE, "false") == "true"
if is_preemptible:
instance_type = instance_type + "-preemptible"
Expand Down

0 comments on commit b48b59a

Please sign in to comment.