Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deployctl output to note demos #1657

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions deploy/deployctl/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,26 @@ def kubectl(args: typing.List[str], **kwargs) -> str:
)


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


def get_most_recent_k8s_deployment(selector: str) -> str:
deployments = get_k8s_deployments(selector)
if not deployments:
raise RuntimeError(f"No deployment matching '{selector}' found")
return deployments[len(deployments) - 1]
return deployments[len(deployments) - 1][0]


def k8s_deployment_exists(k8s_deployment_name: str) -> bool:
Expand Down
25 changes: 22 additions & 3 deletions deploy/deployctl/subcommands/browser_deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,38 @@ def deployments_directory() -> str:
return path


def print_pool_name(pool: str) -> str:
if pool == "demo-pool":
return "(demo)"
if pool == "main-pool":
return ""

return pool


def determine_deployment_pool(path: str) -> str:
with open(path) as f:
content = f.read()
return "demo-pool" if "'demo-pool'" in content or '"demo-pool"' in content else "main-pool"


def list_deployments() -> None:
print("Local configurations")
print("====================")
paths = reversed(sorted(glob.iglob(f"{deployments_directory()}/*/kustomization.yaml"), key=os.path.getmtime))
for path in paths:
print(os.path.basename(os.path.dirname(path)))
name = os.path.basename(os.path.dirname(path))
pool = determine_deployment_pool(path)
print(f"{name} {print_pool_name(pool)}")

print()

print("Cluster deployments")
print("===================")
for deployment in get_k8s_deployments("component=gnomad-browser"):
print(deployment[len("gnomad-browser-") :])
for deployment, pool in get_k8s_deployments("component=gnomad-browser"):
print(f"{deployment[len('gnomad-browser-'):]} {print_pool_name(pool)}")

print()


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