Skip to content

Commit f11a262

Browse files
committed
Change KinD config to listen on all interfaces (0.0.0.0) -> needed to allow Docker container to access localhost cluster. Set KUBECONFIG in Docker container when running k8s.
1 parent 939dcbd commit f11a262

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

.github/workflows/run-scenario.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
cp "$HOME/.kube/config" "./kubeconfig/config"
4949
chmod +r ./kubeconfig/config
5050
# Modify the kubeconfig to use host.docker.internal
51-
sed -i 's/127.0.0.1/host.docker.internal/g' ./kubeconfig/config
51+
sed -i 's/0.0.0.0/host.docker.internal/g' ./kubeconfig/config
5252
5353
- name: Install dependencies
5454
run: pip install tomli tomli-w pyyaml requests

generate_compose.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,16 @@ def generate_docker_compose(scenario: dict[str, Any], app: str) -> str:
202202
])
203203

204204
all_services = ["green-agent"] + participant_names
205+
green_env = green.get("env", {})
206+
207+
if app == "k8s":
208+
# For k8s app, set KUBECONFIG env var for green agent
209+
green_env["KUBECONFIG"] = "/root/.kube/config"
205210

206211
return COMPOSE_TEMPLATE.format(
207212
green_image=green["image"],
208213
green_port=DEFAULT_PORT,
209-
green_env=format_env_vars(green.get("env", {})),
214+
green_env=format_env_vars(green_env),
210215
green_depends=format_depends_on(participant_names),
211216
participant_services=participant_services,
212217
client_depends=format_depends_on(all_services),

kind_config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: kind.x-k8s.io/v1alpha4
33
networking:
44
# WARNING: It is _strongly_ recommended that you keep this the default
55
# (127.0.0.1) for security reasons. However it is possible to change this.
6-
apiServerAddress: "127.0.0.1"
6+
apiServerAddress: "0.0.0.0"
77
# By default the API server listens on a random open port.
88
# You may choose a specific port but probably don't need to in most cases.
99
# Using a random port makes it easier to spin up multiple clusters.
@@ -13,6 +13,7 @@ kubeadmConfigPatches:
1313
kind: ClusterConfiguration
1414
apiServer:
1515
certSANs:
16+
- "0.0.0.0"
1617
- "localhost"
1718
- "127.0.0.1"
1819
- "host.docker.internal"

0 commit comments

Comments
 (0)