Skip to content

Commit

Permalink
feat: Enable local docker ip in for communication with outside k3d (#…
Browse files Browse the repository at this point in the history
…11350)

Signed-off-by: Matthias Dietz <m.dietz@ewerk.com>
Co-authored-by: Matthias Dietz <m.dietz@ewerk.com>
  • Loading branch information
devops-42 and devops-42 authored Jul 13, 2023
1 parent 43d667e commit d992ec5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion .devcontainer/pre-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 -
2 changes: 1 addition & 1 deletion docs/running-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 URL can be used in the workflow spec: `host.docker.internal:<PORT>`. 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:

Expand Down

0 comments on commit d992ec5

Please sign in to comment.