@@ -62,6 +62,7 @@ def fetch_agent_info(agentbeats_id: str) -> dict:
6262 image: {green_image}
6363 platform: linux/amd64
6464 container_name: green-agent
65+ privileged: {privileged} # Needed for route-agent (to run Mininet).
6566 command: ["--host", "0.0.0.0", "--port", "{green_port}", "--card-url", "http://green-agent:{green_port}"]
6667 environment:{green_env}
6768 healthcheck:
@@ -73,6 +74,7 @@ def fetch_agent_info(agentbeats_id: str) -> dict:
7374 depends_on:{green_depends}
7475 networks:
7576 - agent-network
77+ {k8s_service_options}
7678
7779{participant_services}
7880 agentbeats-client:
@@ -175,12 +177,19 @@ def format_depends_on(services: list) -> str:
175177 return "\n " + "\n " .join (lines )
176178
177179
178- def generate_docker_compose (scenario : dict [str , Any ]) -> str :
180+ def generate_docker_compose (scenario : dict [str , Any ], app : str ) -> str :
179181 green = scenario ["green_agent" ]
180182 participants = scenario .get ("participants" , [])
181183
182184 participant_names = [p ["name" ] for p in participants ]
183185
186+ # Expose kubeconfig and localhost for k8s app to allow communication with kind cluster
187+ k8s_service_options = """extra_hosts:
188+ - "host.docker.internal:host-gateway"
189+ volumes:
190+ - ./kubeconfig:/root/.kube/:ro
191+ """
192+
184193 participant_services = "\n " .join ([
185194 PARTICIPANT_TEMPLATE .format (
186195 name = p ["name" ],
@@ -192,14 +201,21 @@ def generate_docker_compose(scenario: dict[str, Any]) -> str:
192201 ])
193202
194203 all_services = ["green-agent" ] + participant_names
204+ green_env = green .get ("env" , {})
205+
206+ if app == "k8s" :
207+ # For k8s app, set KUBECONFIG env var for green agent
208+ green_env ["KUBECONFIG" ] = "/root/.kube/config"
195209
196210 return COMPOSE_TEMPLATE .format (
197211 green_image = green ["image" ],
198212 green_port = DEFAULT_PORT ,
199- green_env = format_env_vars (green . get ( "env" , {}) ),
213+ green_env = format_env_vars (green_env ),
200214 green_depends = format_depends_on (participant_names ),
201215 participant_services = participant_services ,
202- client_depends = format_depends_on (all_services )
216+ client_depends = format_depends_on (all_services ),
217+ privileged = str (app == "route" ).lower (),
218+ k8s_service_options = k8s_service_options if app == "k8s" else ""
203219 )
204220
205221
@@ -259,6 +275,7 @@ def generate_env_file(scenario: dict[str, Any]) -> str:
259275def main ():
260276 parser = argparse .ArgumentParser (description = "Generate Docker Compose from scenario.toml" )
261277 parser .add_argument ("--scenario" , type = Path )
278+ parser .add_argument ("--app" , type = str , choices = ["malt" , "route" , "k8s" ], default = "malt" , help = "What app to generate for." )
262279 args = parser .parse_args ()
263280
264281 if not args .scenario .exists ():
@@ -268,7 +285,7 @@ def main():
268285 scenario = parse_scenario (args .scenario )
269286
270287 with open (COMPOSE_PATH , "w" ) as f :
271- f .write (generate_docker_compose (scenario ))
288+ f .write (generate_docker_compose (scenario , args . app ))
272289
273290 with open (A2A_SCENARIO_PATH , "w" ) as f :
274291 f .write (generate_a2a_scenario (scenario ))
0 commit comments