-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4cb5f62
commit 5894708
Showing
5 changed files
with
227 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import Dict, Any | ||
import os | ||
import json | ||
import jsonschema | ||
|
||
ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../') | ||
CONFIG_DIR = os.path.join(ROOT_DIR, 'config/papyrus/') | ||
|
||
|
||
class Config(): | ||
def __init__(self, schema: Dict[Any, Any], config: Dict[Any, Any]): | ||
self.schema = schema | ||
self.config = config | ||
|
||
def get(self): | ||
return self.config | ||
|
||
def validate(self): | ||
pass | ||
|
||
|
||
class SequencerDevConfig(Config): | ||
def __init__(self): | ||
super().__init__( | ||
schema=json.loads(open(os.path.join(CONFIG_DIR, 'default_config.json'), 'r').read()), | ||
config=json.loads(open(os.path.join(CONFIG_DIR, 'presets', 'sepolia_testnet.json'), 'r').read()) | ||
) | ||
|
||
def validate(self): | ||
jsonschema.validate(self.config, schema=self.schema) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,53 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from re import S | ||
from constructs import Construct | ||
from cdk8s import App, Chart | ||
from typing import Dict, Any | ||
from services.service import Service | ||
import dataclasses | ||
|
||
from config.sequencer import Config, SequencerDevConfig | ||
|
||
|
||
@dataclasses.dataclass | ||
class SystemStructure: | ||
topology: str = "mesh" | ||
replicas: str = "2" | ||
size: str = "small" | ||
config: Config = SequencerDevConfig() | ||
|
||
def __post_init__(self): | ||
self.config.validate() | ||
|
||
|
||
class SequencerSystem(Chart): | ||
def __init__(self, scope: Construct, name: str, namespace: str, system_structure: Dict[str, Dict[str, Any]]): | ||
def __init__( | ||
self, | ||
scope: Construct, | ||
name: str, | ||
namespace: str, | ||
system_structure: Dict[str, Dict[str, Any]], | ||
): | ||
super().__init__( | ||
scope, name, disable_resource_name_hashes=True, namespace=namespace | ||
) | ||
self.mempool = Service(self, "mempool", image="paulbouwer/hello-kubernetes:1.7", replicas=2, config={"message": "Hello, Kubernetes!"}) | ||
breakpoint() | ||
self.mempool = Service( | ||
self, | ||
"mempool", | ||
image="paulbouwer/hello-kubernetes:1.7", | ||
replicas=2, | ||
config=system_structure.config.get(), | ||
) | ||
self.batcher = Service(self, "batcher", image="ghost", container_port=2368) | ||
|
||
def validate(self): | ||
pass | ||
|
||
|
||
app_1 = App() | ||
a = SequencerSystem( | ||
scope=app_1, | ||
name="sequencer-system-1", | ||
namespace="alond", | ||
system_structure=SystemStructure() | ||
system_structure=SystemStructure(), | ||
) | ||
|
||
a.validate() | ||
app_1.synth() |
Oops, something went wrong.