|
1 | 1 | #!/usr/bin/env python |
| 2 | + |
| 3 | +import argparse |
2 | 4 | from cdk8s import App, Chart, Names, YamlOutputType |
3 | 5 | from constructs import Construct |
4 | 6 | from imports import k8s |
5 | 7 |
|
6 | 8 |
|
| 9 | +def get_args(): |
| 10 | + parser = argparse.ArgumentParser() |
| 11 | + parser.add_argument( |
| 12 | + "--namespace", |
| 13 | + required=True, |
| 14 | + help="Kubernetes namespace to deploy to." |
| 15 | + ) |
| 16 | + parser.add_argument( |
| 17 | + "--image", |
| 18 | + required=False, |
| 19 | + default="us-central1-docker.pkg.dev/starkware-dev/sequencer/dummy_recorder:latest", |
| 20 | + help="Docker image to deploy. Defaults to the latest dummy recorder image." |
| 21 | + ) |
| 22 | + return parser.parse_args() |
| 23 | + |
| 24 | + |
7 | 25 | class DummyRecorder(Chart): |
8 | | - def __init__(self, scope: Construct, id: str, namespace: str): |
| 26 | + def __init__(self, scope: Construct, id: str, namespace: str, image: str): |
9 | 27 | super().__init__(scope, id, disable_resource_name_hashes=True, namespace=namespace) |
10 | 28 |
|
11 | 29 | self.label = {"app": Names.to_label_value(self, include_hash=False)} |
@@ -37,7 +55,7 @@ def __init__(self, scope: Construct, id: str, namespace: str): |
37 | 55 | containers=[ |
38 | 56 | k8s.Container( |
39 | 57 | name=self.node.id, |
40 | | - image="us-central1-docker.pkg.dev/starkware-dev/sequencer/dummy_recorder:latest", |
| 58 | + image=image, |
41 | 59 | env=[k8s.EnvVar(name="RUST_LOG", value="DEBUG")], |
42 | 60 | ports=[k8s.ContainerPort(container_port=8080)], |
43 | 61 | ) |
@@ -80,7 +98,14 @@ def __init__(self, scope: Construct, id: str, namespace: str): |
80 | 98 | ) |
81 | 99 |
|
82 | 100 |
|
83 | | -app = App(yaml_output_type=YamlOutputType.FOLDER_PER_CHART_FILE_PER_RESOURCE) |
84 | | -DummyRecorder(scope=app, id="dummy-recorder", namespace="dummy-recorder") |
| 101 | +if __name__ == "__main__": |
| 102 | + args = get_args() |
85 | 103 |
|
86 | | -app.synth() |
| 104 | + app = App(yaml_output_type=YamlOutputType.FOLDER_PER_CHART_FILE_PER_RESOURCE) |
| 105 | + DummyRecorder( |
| 106 | + scope=app, |
| 107 | + id="dummy-recorder", |
| 108 | + namespace=args.namespace, |
| 109 | + image=args.image |
| 110 | + ) |
| 111 | + app.synth() |
0 commit comments