From 6553eccd618b51e5ef89cefa8011da265fcd83ff Mon Sep 17 00:00:00 2001 From: Matthias Dietz Date: Thu, 13 Jul 2023 13:38:52 +0200 Subject: [PATCH 1/4] Inject `host.docker.internal` into devcontainer and k3d cluster Signed-off-by: Matthias Dietz --- .devcontainer/devcontainer.json | 1 + .devcontainer/pre-build.sh | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 58b30098a783..afcded3ec1c7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -15,6 +15,7 @@ "hostRequirements": { "cpus": 4 }, + "runArgs": ["--add-host=host.docker.internal:host-gateway"], "onCreateCommand": ".devcontainer/pre-build.sh", "workspaceMount": "source=${localWorkspaceFolder},target=/home/vscode/go/src/github.com/argoproj/argo-workflows,type=bind", "workspaceFolder": "/home/vscode/go/src/github.com/argoproj/argo-workflows", diff --git a/.devcontainer/pre-build.sh b/.devcontainer/pre-build.sh index 1b89cb91a514..1edc83b1669a 100755 --- a/.devcontainer/pre-build.sh +++ b/.devcontainer/pre-build.sh @@ -31,3 +31,6 @@ sudo chown -R vscode:vscode /home/vscode/go # download dependencies and do first-pass compile CI=1 kit pre-up + +# Patch CoreDNS to have host.docker.internal inside the cluster available +kubectl get cm coredns -n kube-system -o yaml | sed "s/ NodeHosts: |/ NodeHosts: |\n `grep host.docker.internal /etc/hosts`/" | kubectl apply -f - From 27999f7f035edb1b646c5e57394856b03d750c19 Mon Sep 17 00:00:00 2001 From: Matthias Dietz Date: Thu, 13 Jul 2023 13:39:51 +0200 Subject: [PATCH 2/4] Enable multi-arch download for `kubectl` Signed-off-by: Matthias Dietz --- .devcontainer/pre-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/pre-build.sh b/.devcontainer/pre-build.sh index 1edc83b1669a..c62b8a4583e8 100755 --- a/.devcontainer/pre-build.sh +++ b/.devcontainer/pre-build.sh @@ -14,7 +14,7 @@ k3d cluster get k3s-default || k3d cluster create --wait k3d kubeconfig merge --kubeconfig-merge-default # install kubectl -curl -LO https://dl.k8s.io/release/v1.26.0/bin/linux/amd64/kubectl +curl -LO https://dl.k8s.io/release/v1.26.0/bin/linux/$(go env GOARCH)/kubectl chmod +x ./kubectl sudo mv ./kubectl /usr/local/bin/kubectl kubectl cluster-info From a8aa97073ca61c84404f2436187d3c8575e55fa0 Mon Sep 17 00:00:00 2001 From: Matthias Dietz Date: Thu, 13 Jul 2023 20:22:55 +0200 Subject: [PATCH 3/4] feat: Added documentation for the communication hostname setup Signed-off-by: Matthias Dietz --- docs/running-locally.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/running-locally.md b/docs/running-locally.md index 6156cdfe61a1..543921011299 100644 --- a/docs/running-locally.md +++ b/docs/running-locally.md @@ -12,7 +12,7 @@ generation does not work. ## Development Container -A development container is a running Docker container with a well-defined tool/runtime stack and its prerequisites. It should be able to do everything you need to do to develop argo workflows using the development container without installing tools on your local machine. It takes quite a long time to build the container. It will run k3d inside the container so you'll have a cluster to use to test against. +A development container is a running Docker container with a well-defined tool/runtime stack and its prerequisites. It should be able to do everything you need to do to develop argo workflows using the development container without installing tools on your local machine. It takes quite a long time to build the container. It will run k3d inside the container so you'll have a cluster to use to test against. To communicate with services running either in other development containers or directly on the local developer machine (e.g., a database) the following combination of hostname and port can be used in the workflow spec: `host.docker.internal:`. This facilitates the implementation of workflows, which need to connect to a database or an API server. You can use the development container in a few different ways: From 59b207000ceaba5cb531fd5facc0a5653dd51cdd Mon Sep 17 00:00:00 2001 From: Matthias Dietz Date: Thu, 13 Jul 2023 20:22:55 +0200 Subject: [PATCH 4/4] feat: Added documentation for the communication hostname setup Signed-off-by: Matthias Dietz --- docs/running-locally.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/running-locally.md b/docs/running-locally.md index 543921011299..d943fcc36cbf 100644 --- a/docs/running-locally.md +++ b/docs/running-locally.md @@ -12,7 +12,7 @@ generation does not work. ## Development Container -A development container is a running Docker container with a well-defined tool/runtime stack and its prerequisites. It should be able to do everything you need to do to develop argo workflows using the development container without installing tools on your local machine. It takes quite a long time to build the container. It will run k3d inside the container so you'll have a cluster to use to test against. To communicate with services running either in other development containers or directly on the local developer machine (e.g., a database) the following combination of hostname and port can be used in the workflow spec: `host.docker.internal:`. This facilitates the implementation of workflows, which need to connect to a database or an API server. +A development container is a running Docker container with a well-defined tool/runtime stack and its prerequisites. It should be able to do everything you need to do to develop argo workflows using the development container without installing tools on your local machine. It takes quite a long time to build the container. It will run k3d inside the container so you'll have a cluster to use to test against. To communicate with services running either in other development containers or directly on the local developer machine (e.g., a database) the following URL can be used in the workflow spec: `host.docker.internal:`. This facilitates the implementation of workflows, which need to connect to a database or an API server. You can use the development container in a few different ways: