Skip to content

Commit

Permalink
Added healthcheck probes
Browse files Browse the repository at this point in the history
  • Loading branch information
idan-starkware committed Nov 3, 2024
1 parent a298cf0 commit 9c8cad0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
10 changes: 10 additions & 0 deletions deployments/sequencer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,18 @@ def __init__(
image="paulbouwer/hello-kubernetes:1.7",
replicas=2,
config=system_structure.config.get(),
probe_path=""
)
self.batcher = Service(self, "batcher", image="ghost", container_port=2368)
self.sequencer_node = Service(
self,
"sequencer",
image="",
container_port=8082,
startup_probe_path="/monitoring/nodeVersion",
readiness_probe_path="/monitoring/ready",
liveness_probe_path="/monitoring/alive"
)


app = App()
Expand Down
29 changes: 22 additions & 7 deletions deployments/sequencer/services/service.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from typing import Optional, Dict
import json

from typing import Optional, Dict, Union
from constructs import Construct
from cdk8s import Names
import json
from imports import k8s

from imports import k8s

class Service(Construct):
def __init__(
Expand All @@ -14,8 +15,12 @@ def __init__(
image: str,
replicas: int = 1,
port: Optional[int] = 80,
container_port: int = 8080,
container_port: int = 8082,
config: Optional[Dict[str, str]] = None,
startup_probe_path: Optional[str] = "/",
readiness_probe_path: Optional[str] = "/",
liveness_probe_path: Optional[str] = "/"

):
super().__init__(scope, id)

Expand Down Expand Up @@ -59,15 +64,25 @@ def __init__(
ports=[
k8s.ContainerPort(container_port=container_port)
],
startup_probe=k8s.Probe(
http_get=k8s.HttpGetAction(port=k8s.IntOrString.from_string('http'), path=startup_probe_path),
period_seconds=10, failure_threshold=12, timeout_seconds=5
),
readiness_probe=k8s.Probe(
http_get=k8s.HttpGetAction(port=k8s.IntOrString.from_string('http'), path=readiness_probe_path),
period_seconds=10, failure_threshold=3, timeout_seconds=5
),
liveness_probe=k8s.Probe(
http_get=k8s.HttpGetAction(port=k8s.IntOrString.from_string('http'), path=liveness_probe_path),
period_seconds=5, failure_threshold=5, timeout_seconds=5
)
)
],
volumes=(
[
k8s.Volume(
name=service_config.name,
config_map=k8s.ConfigMapVolumeSource(
name=service_config.name
),
config_map=k8s.ConfigMapVolumeSource(name=service_config.name),
)
]
if config is not None
Expand Down

0 comments on commit 9c8cad0

Please sign in to comment.