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

Commit

Permalink
Add support for custom label names (#99)
Browse files Browse the repository at this point in the history
* add support for custom label names

* update readme

* fix readme
  • Loading branch information
tomislater authored and hjacobs committed Jul 24, 2019
1 parent 6b90169 commit 3225951
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
15 changes: 15 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,18 @@ with the links per entity. Example file:
For available icon names, see the `Font Awesome gallery with free icons <https://fontawesome.com/icons?d=gallery&m=free>`_.


--------
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"``)
14 changes: 7 additions & 7 deletions kube_resource_report/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import collections
import csv
import os
import pickle
import datetime
import json
Expand All @@ -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
Expand Down

0 comments on commit 3225951

Please sign in to comment.