Create multiple clusters with multiple nodes and replicas each
(c: Composition, parser: WorkflowArgumentParser)
| 2398 | |
| 2399 | |
| 2400 | def workflow_instance_size(c: Composition, parser: WorkflowArgumentParser) -> None: |
| 2401 | """Create multiple clusters with multiple nodes and replicas each""" |
| 2402 | |
| 2403 | parser.add_argument( |
| 2404 | "--workers", |
| 2405 | type=int, |
| 2406 | metavar="N", |
| 2407 | default=2, |
| 2408 | help="set the default number of workers", |
| 2409 | ) |
| 2410 | |
| 2411 | parser.add_argument( |
| 2412 | "--clusters", |
| 2413 | type=int, |
| 2414 | metavar="N", |
| 2415 | default=8, |
| 2416 | help="set the number of clusters to create", |
| 2417 | ) |
| 2418 | parser.add_argument( |
| 2419 | "--replicas", |
| 2420 | type=int, |
| 2421 | metavar="N", |
| 2422 | default=4, |
| 2423 | help="set the number of replicas per cluster", |
| 2424 | ) |
| 2425 | parser.add_argument( |
| 2426 | "--nodes", |
| 2427 | type=int, |
| 2428 | metavar="N", |
| 2429 | default=4, |
| 2430 | help="set the number of nodes per cluster replica", |
| 2431 | ) |
| 2432 | args = parser.parse_args() |
| 2433 | |
| 2434 | assert args.clusters <= MAX_CLUSTERS, "SERVICES have to be static" |
| 2435 | assert args.replicas <= MAX_REPLICAS, "SERVICES have to be static" |
| 2436 | assert args.nodes <= MAX_NODES, "SERVICES have to be static" |
| 2437 | |
| 2438 | c.up( |
| 2439 | "kafka", |
| 2440 | "schema-registry", |
| 2441 | "materialized", |
| 2442 | "balancerd", |
| 2443 | "frontegg-mock", |
| 2444 | Service("testdrive", idle=True), |
| 2445 | ) |
| 2446 | |
| 2447 | # Construct the requied Clusterd instances and peer them into clusters |
| 2448 | node_names = [] |
| 2449 | node_overrides = [] |
| 2450 | for cluster_id in range(1, args.clusters + 1): |
| 2451 | for replica_id in range(1, args.replicas + 1): |
| 2452 | names = [ |
| 2453 | f"clusterd_{cluster_id}_{replica_id}_{i}" |
| 2454 | for i in range(1, args.nodes + 1) |
| 2455 | ] |
| 2456 | for node_name in names: |
| 2457 | node_names.append(node_name) |