Skip to content

Commit 3d2d712

Browse files
committed
add namespace labels
1 parent b5f5656 commit 3d2d712

File tree

6 files changed

+25
-3
lines changed

6 files changed

+25
-3
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: {{ .Release.Namespace }}
5+
labels:
6+
type: {{ .Values.type }}
7+
annotations:
8+
"helm.sh/hook": pre-install
9+
"helm.sh/hook-weight": "-1"

resources/charts/bitcoincore/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,4 @@ connect: []
137137
loadSnapshot:
138138
enabled: false
139139
url: ""
140+
type: "assets"

resources/charts/namespaces/templates/namespace.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ apiVersion: v1
22
kind: Namespace
33
metadata:
44
name: {{ .Values.namespaceName | default .Release.Name }}
5+
labels:
6+
type: {{ .Values.type }}

resources/charts/namespaces/values.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
type: "assets"
12
users:
23
- name: warnet-user
34
roles:
@@ -37,4 +38,4 @@ roles:
3738
verbs: ["get", "list"]
3839
- apiGroups: [""]
3940
resources: ["events"]
40-
verbs: ["get"]
41+
verbs: ["get"]

src/warnet/constants.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
INGRESS_NAMESPACE = "ingress"
1717
HELM_COMMAND = "helm upgrade --install --create-namespace"
1818

19+
# labels are applied to namespaces to help filter commands without relying on naming conventions
20+
# on the namespaces themselves. Namespaces containing tanks and commanders get the WARNET_ASSETS tag
21+
# whereas logging namespaces get the WARNET_LOGGING tag, and admin namespaces get the WARNET_ADMIN tag
22+
WARNET_ASSETS = "assets"
23+
WARNET_LOGGING = "logging"
24+
WARNET_ADMIN = "admin"
25+
26+
1927
# Directories and files for non-python assets, e.g., helm charts, example scenarios, default configs
2028
SRC_DIR = files("warnet")
2129
RESOURCES_DIR = files("resources")

src/warnet/deploy.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
NAMESPACES_CHART_LOCATION,
2020
NAMESPACES_FILE,
2121
NETWORK_FILE,
22+
WARNET_ASSETS,
2223
)
2324
from .k8s import get_default_namespace, wait_for_ingress_controller, wait_for_pod_ready
2425
from .process import stream_command
@@ -209,7 +210,7 @@ def deploy_network(directory: Path, namespace_override: str, debug: bool = False
209210
node_name = node.get("name")
210211
node_config_override = {k: v for k, v in node.items() if k != "name"}
211212

212-
cmd = f"{HELM_COMMAND} {node_name} {BITCOIN_CHART_LOCATION} --namespace {namespace} -f {defaults_file_path}"
213+
cmd = f"{HELM_COMMAND} {node_name} {BITCOIN_CHART_LOCATION} --namespace {namespace} -f {defaults_file_path} --set type={WARNET_ASSETS}"
213214
if debug:
214215
cmd += " --debug"
215216

@@ -246,7 +247,7 @@ def deploy_namespaces(directory: Path):
246247
namespace_name = namespace.get("name")
247248
namespace_config_override = {k: v for k, v in namespace.items() if k != "name"}
248249

249-
cmd = f"{HELM_COMMAND} {namespace_name} {NAMESPACES_CHART_LOCATION} -f {defaults_file_path}"
250+
cmd = f"{HELM_COMMAND} {namespace_name} {NAMESPACES_CHART_LOCATION} -f {defaults_file_path} --set type={WARNET_ASSETS}"
250251

251252
if namespace_config_override:
252253
with tempfile.NamedTemporaryFile(

0 commit comments

Comments
 (0)