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

Updates ingress_production to use the static service names #1632

Merged
merged 1 commit into from
Sep 20, 2024
Merged
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
45 changes: 5 additions & 40 deletions deploy/deployctl/subcommands/ingress_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,6 @@
ports:
- port: 80
targetPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: gnomad-reads
labels:
tier: production
spec:
type: NodePort
selector:
name: gnomad-reads
deployment: '{reads_deployment}'
ports:
- port: 80
targetPort: 80
"""


Expand All @@ -51,20 +36,13 @@ def get_current_browser_deployment() -> str:
return browser_manifest["spec"]["selector"]["deployment"]


def get_current_reads_deployment() -> str:
reads_manifest = json.loads(kubectl(["get", "service", "gnomad-reads", "--output=json"]))
return reads_manifest["spec"]["selector"]["deployment"]


def describe_services() -> None:
browser_deployment = get_current_browser_deployment()
reads_deployment = get_current_reads_deployment()

print("active browser deployment:", browser_deployment)
print("active reads deployment:", reads_deployment)


def apply_services(browser_deployment: str = None, reads_deployment: str = None) -> None:
def apply_services(browser_deployment: str = None) -> None:
if browser_deployment:
if not k8s_deployment_exists(f"gnomad-browser-{browser_deployment}"):
raise RuntimeError(f"browser deployment {browser_deployment} not found")
Expand All @@ -74,26 +52,15 @@ def apply_services(browser_deployment: str = None, reads_deployment: str = None)
except Exception: # pylint: disable=broad-except; FIXME: Use a more specific exception class
browser_deployment = get_most_recent_k8s_deployment("component=gnomad-browser")[len("gnomad-browser-") :]

if reads_deployment:
if not k8s_deployment_exists(f"gnomad-reads-{reads_deployment}"):
raise RuntimeError(f"reads deployment {reads_deployment} not found")
else:
try:
reads_deployment = get_current_reads_deployment()
except Exception: # pylint: disable=broad-except; FIXME: Use a more specific exception class
reads_deployment = get_most_recent_k8s_deployment("component=gnomad-reads")[len("gnomad-reads-") :]

manifest = SERVICES_MANIFEST_TEMPLATE.format(
browser_deployment=browser_deployment, reads_deployment=reads_deployment
)
manifest = SERVICES_MANIFEST_TEMPLATE.format(browser_deployment=browser_deployment)

kubectl(["apply", "-f", "-"], input=manifest)

print(f"Updated production ingresses. browser: '{browser_deployment}', reads: '{reads_deployment}' ")
print(f"Updated production ingresses. browser: '{browser_deployment}' ")


def apply_ingress(browser_deployment: str = None, reads_deployment: str = None, quiet: bool = False) -> None:
apply_services(browser_deployment, reads_deployment)
def apply_ingress(browser_deployment: str = None, quiet: bool = False) -> None:
apply_services(browser_deployment)

if quiet or input("Apply changes to production ingress (y/n) ").lower() == "y":
kubectl(["apply", "-f", os.path.join(manifests_directory(), "gnomad.backendconfig.yaml")])
Expand All @@ -112,12 +79,10 @@ def main(argv: typing.List[str]) -> None:
apply_services_parser = subparsers.add_parser("update")
apply_services_parser.set_defaults(action=apply_services)
apply_services_parser.add_argument("--browser-deployment")
apply_services_parser.add_argument("--reads-deployment")

apply_ingress_parser = subparsers.add_parser("apply-ingress")
apply_ingress_parser.set_defaults(action=apply_ingress)
apply_ingress_parser.add_argument("--browser-deployment")
apply_ingress_parser.add_argument("--reads-deployment")
apply_ingress_parser.add_argument("--quiet", action="store_true")

args = parser.parse_args(argv)
Expand Down
18 changes: 16 additions & 2 deletions deploy/manifests/ingress/gnomad.ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,32 @@ spec:
paths:
- backend:
service:
name: gnomad-reads
name: reads-bluegreen-active-prod
port:
number: 80
path: /reads
pathType: ImplementationSpecific
- backend:
service:
name: gnomad-reads
name: reads-bluegreen-active-prod
port:
number: 80
path: /reads/*
pathType: ImplementationSpecific
- backend:
service:
name: reads-bluegreen-preview-prod
port:
number: 80
path: /preview-reads
pathType: ImplementationSpecific
- backend:
service:
name: reads-bluegreen-preview-prod
port:
number: 80
path: /preview-reads/*
pathType: ImplementationSpecific
- backend:
service:
name: gnomad-blog
Expand Down
Loading