diff --git a/README.rst b/README.rst index 7053411..e3a788c 100644 --- a/README.rst +++ b/README.rst @@ -151,3 +151,18 @@ with the links per entity. Example file: For available icon names, see the `Font Awesome gallery with free icons `_. + +-------- +Settings +-------- + +You can run ``docker run --rm hjacobs/kube-resource-report:0.14.1 --help`` to find out information. + +Besides this, you can also pass environment variables: + +- ``NODE_LABEL_SPOT`` (default: ``"aws.amazon.com/spot"``) +- ``NODE_LABEL_ROLE`` (default: ``"kubernetes.io/role"``) +- ``NODE_LABEL_REGION`` (default: ``"failure-domain.beta.kubernetes.io/region"``) +- ``NODE_LABEL_INSTANCE_TYPE`` (default: ``"beta.kubernetes.io/instance-type"``) +- ``OBJECT_LABEL_APPLICATION`` (default: ``"application,app,app.kubernetes.io/name"``) +- ``OBJECT_LABEL_COMPONENT`` (default: ``"component,app.kubernetes.io/component"``) diff --git a/kube_resource_report/report.py b/kube_resource_report/report.py index 2d6e48b..96112c2 100755 --- a/kube_resource_report/report.py +++ b/kube_resource_report/report.py @@ -2,6 +2,7 @@ import collections import csv +import os import pickle import datetime import json @@ -23,16 +24,15 @@ from .output import OutputManager -# TODO: this should be configurable -NODE_LABEL_SPOT = "aws.amazon.com/spot" -NODE_LABEL_ROLE = "kubernetes.io/role" +NODE_LABEL_SPOT = os.environ.get("NODE_LABEL_SPOT", "aws.amazon.com/spot") +NODE_LABEL_ROLE = os.environ.get("NODE_LABEL_ROLE", "kubernetes.io/role") # the following labels are used by both AWS and GKE -NODE_LABEL_REGION = "failure-domain.beta.kubernetes.io/region" -NODE_LABEL_INSTANCE_TYPE = "beta.kubernetes.io/instance-type" +NODE_LABEL_REGION = os.environ.get("NODE_LABEL_REGION", "failure-domain.beta.kubernetes.io/region") +NODE_LABEL_INSTANCE_TYPE = os.environ.get("NODE_LABEL_INSTANCE_TYPE", "beta.kubernetes.io/instance-type") # https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/#labels -OBJECT_LABEL_APPLICATION = ["application", "app", "app.kubernetes.io/name"] -OBJECT_LABEL_COMPONENT = ["component", "app.kubernetes.io/component"] +OBJECT_LABEL_APPLICATION = os.environ.get("OBJECT_LABEL_APPLICATION", "application,app,app.kubernetes.io/name").split(",") +OBJECT_LABEL_COMPONENT = os.environ.get("OBJECT_LABEL_COMPONENT", "component,app.kubernetes.io/component").split(",") ONE_MEBI = 1024 ** 2 ONE_GIBI = 1024 ** 3