Skip to content

chore(deployment): cdk8s add deployment for dummy_eth2strk_oracle service #5271

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

Merged
merged 1 commit into from
Mar 26, 2025
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
4 changes: 4 additions & 0 deletions deployments/dummy_eth2strk_oracle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__/
.idea/
dist/
imports/
15 changes: 15 additions & 0 deletions deployments/dummy_eth2strk_oracle/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[requires]
python_version = "3"

[packages]
constructs = "~=10.4.2"
cdk8s = "~=2.69.17"
cdk8s-plus-28 = "~=2.5.6"

[pipenv]
allow_prereleases = true
135 changes: 135 additions & 0 deletions deployments/dummy_eth2strk_oracle/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions deployments/dummy_eth2strk_oracle/cdk8s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: python
app: pipenv run python main.py
imports:
- k8s
95 changes: 95 additions & 0 deletions deployments/dummy_eth2strk_oracle/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env python
from constructs import Construct
from cdk8s import App, Chart, Names, YamlOutputType
from imports import k8s


SERVICE_NAME = "dummy-eth2strk-oracle"
SERVICE_PORT = 9000
CLUSTER = "sequencer-dev"
NAMESPACE = "dummy-eth2strk-oracle"
IMAGE = "us-central1-docker.pkg.dev/starkware-dev/sequencer/dummy_eth2strk_oracle:latest"


class DummyEth2StrkOracle(Chart):
def __init__(self, scope: Construct, id: str, namespace: str):
super().__init__(scope, id, disable_resource_name_hashes=True, namespace=namespace)

self.label = {"app": Names.to_label_value(self, include_hash=False)}
self.host = f"{self.node.id}.{CLUSTER}.sw-dev.io"

k8s.KubeService(
self,
"service",
spec=k8s.ServiceSpec(
type="ClusterIP",
ports=[
k8s.ServicePort(
name="http",
port=SERVICE_PORT,
target_port=k8s.IntOrString.from_number(SERVICE_PORT),
),
],
selector=self.label,
),
)

k8s.KubeDeployment(
self,
"deployment",
spec=k8s.DeploymentSpec(
replicas=1,
selector=k8s.LabelSelector(match_labels=self.label),
template=k8s.PodTemplateSpec(
metadata=k8s.ObjectMeta(labels=self.label),
spec=k8s.PodSpec(
containers=[
k8s.Container(
name=self.node.id,
image=IMAGE,
env=[k8s.EnvVar(name="RUST_LOG", value="DEBUG")],
ports=[k8s.ContainerPort(container_port=SERVICE_PORT)],
)
],
),
),
),
)

k8s.KubeIngress(
self,
"ingress",
metadata=k8s.ObjectMeta(
name=f"{self.node.id}-ingress",
labels=self.label,
annotations={"nginx.ingress.kubernetes.io/rewrite-target": "/"},
),
spec=k8s.IngressSpec(
ingress_class_name="nginx",
rules=[
k8s.IngressRule(
host=self.host,
http=k8s.HttpIngressRuleValue(
paths=[
k8s.HttpIngressPath(
path="/",
path_type="ImplementationSpecific",
backend=k8s.IngressBackend(
service=k8s.IngressServiceBackend(
name=f"{self.node.id}-service",
port=k8s.ServiceBackendPort(number=SERVICE_PORT),
)
),
)
]
),
)
],
),
)


app = App(yaml_output_type=YamlOutputType.FOLDER_PER_CHART_FILE_PER_RESOURCE)
DummyEth2StrkOracle(scope=app, id=SERVICE_NAME, namespace=NAMESPACE)

app.synth()
Loading