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 f26dae8
Showing 1 changed file with 22 additions and 7 deletions.
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 f26dae8

Please sign in to comment.