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

Commit

Permalink
Allow overriding default cluster name
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinbunney committed Apr 30, 2020
1 parent b48b59a commit bd4a986
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,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:

- ``DEFAULT_CLUSTER_NAME`` (default: ``"cluster"``)
- ``NODE_LABEL_SPOT`` (default: ``"aws.amazon.com/spot"``)
- ``NODE_LABEL_SPOT_VALUE`` (default: ``"true"``)
- ``NODE_LABEL_PREEMPTIBLE`` (default: ``cloud.google.com/gke-preemptible``)
Expand Down
6 changes: 4 additions & 2 deletions kube_resource_report/cluster_discovery.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
import re
import time
from pathlib import Path
Expand All @@ -13,6 +14,7 @@

# default URL points to kubectl proxy
DEFAULT_CLUSTERS = "http://localhost:8001/"
DEFAULT_CLUSTER_NAME = os.environ.get("DEFAULT_CLUSTER_NAME", "cluster")
CLUSTER_ID_INVALID_CHARS = re.compile("[^a-z0-9:-]")

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -64,15 +66,15 @@ def __init__(self, api_server_urls: list):
client = HTTPClient(config)
cluster = Cluster(
generate_cluster_id(DEFAULT_CLUSTERS),
"cluster",
DEFAULT_CLUSTER_NAME,
DEFAULT_CLUSTERS,
client,
)
else:
client = HTTPClient(config)
cluster = Cluster(
generate_cluster_id(config.cluster["server"]),
"cluster",
DEFAULT_CLUSTER_NAME,
config.cluster["server"],
client,
)
Expand Down

0 comments on commit bd4a986

Please sign in to comment.