Skip to content

Commit d5dc887

Browse files
committed
feat(deployctl): note when deployment is demo
1 parent 5696124 commit d5dc887

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

deploy/deployctl/shell.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,26 @@ def kubectl(args: typing.List[str], **kwargs) -> str:
3535
)
3636

3737

38-
def get_k8s_deployments(selector: str) -> typing.List[str]:
38+
def get_k8s_deployments(selector: str) -> typing.List[typing.Tuple[str, str]]:
3939
result = kubectl(
4040
[
4141
"get",
4242
"deployments",
4343
f"--selector={selector}",
4444
"--sort-by={.metadata.creationTimestamp}",
45-
"--output=jsonpath={range .items[*]}{.metadata.name}{'\\n'}",
45+
"--output=jsonpath={range .items[*]}{.metadata.name} {.spec.template.spec.nodeSelector.cloud\\.google\\.com/gke-nodepool}{'\\n'}",
4646
]
4747
)
48-
return [line for line in result.splitlines() if line]
48+
return [
49+
(parts[0], parts[1]) for line in result.splitlines() for parts in [line.split(maxsplit=1)] if len(parts) == 2
50+
]
4951

5052

5153
def get_most_recent_k8s_deployment(selector: str) -> str:
5254
deployments = get_k8s_deployments(selector)
5355
if not deployments:
5456
raise RuntimeError(f"No deployment matching '{selector}' found")
55-
return deployments[len(deployments) - 1]
57+
return deployments[len(deployments) - 1][0]
5658

5759

5860
def k8s_deployment_exists(k8s_deployment_name: str) -> bool:

deploy/deployctl/subcommands/browser_deployments.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,38 @@ def deployments_directory() -> str:
115115
return path
116116

117117

118+
def print_pool_name(pool: str) -> str:
119+
if pool == "demo-pool":
120+
return "(demo)"
121+
if pool == "main-pool":
122+
return ""
123+
124+
return pool
125+
126+
127+
def determine_deployment_pool(path: str) -> str:
128+
with open(path) as f:
129+
content = f.read()
130+
return "demo-pool" if "'demo-pool'" in content or '"demo-pool"' in content else "main-pool"
131+
132+
118133
def list_deployments() -> None:
119134
print("Local configurations")
120135
print("====================")
121136
paths = reversed(sorted(glob.iglob(f"{deployments_directory()}/*/kustomization.yaml"), key=os.path.getmtime))
122137
for path in paths:
123-
print(os.path.basename(os.path.dirname(path)))
138+
name = os.path.basename(os.path.dirname(path))
139+
pool = determine_deployment_pool(path)
140+
print(f"{name} {print_pool_name(pool)}")
124141

125142
print()
126143

127144
print("Cluster deployments")
128145
print("===================")
129-
for deployment in get_k8s_deployments("component=gnomad-browser"):
130-
print(deployment[len("gnomad-browser-") :])
146+
for deployment, pool in get_k8s_deployments("component=gnomad-browser"):
147+
print(f"{deployment[len('gnomad-browser-'):]} {print_pool_name(pool)}")
148+
149+
print()
131150

132151

133152
def create_deployment(name: str, browser_tag: str = None, api_tag: str = None, demo: bool = False) -> None:

0 commit comments

Comments
 (0)