Access a local (or remote) Kubernetes cluster from inside a dev container using your local config. Includes kubectl, Helm, and the Docker CLI.
Note: If you would prefer to not set up Kubernetes locally or are using a cloud-based environment, you may find the Kubernetes - Minikube-in-Docker definition more interesting.
Dev containers can be useful for all types of applications including those that also deploy into a container based-environment. While you can directly build and run the application inside the dev container you create, you may also want to test it by deploying a built container image into a local minikube or remote Kubernetes cluster without affecting your dev container.
The included .devcontainer.json
can be altered to work with other Debian/Ubuntu-based container images such as node
or python
. For example, to use mcr.microsoft.com/devcontainers/javascript-node
, update the image
property as follows:
"image": "mcr.microsoft.com/devcontainers/javascript-node:18-bullseye"
While this definition works with Minikube in most cases, if you hit trouble, make sure that your ~/.kube/config
file and Minikube certs reference your host's IP rather than 127.0.0.1
or localhost
(since localhost
resolves to the container itself rather than your local machine where Minikube is running).
This should happen by default on Linux. On macOS and Windows, we recommend using the Kubernetes install that comes with Docker Desktop instead of Minikube to avoid these kinds of issues.
When configuring Ingress for your Kubernetes cluster, note that by default Kubernetes will bind to a specific interface's IP rather than localhost or all interfaces. This is why you need to use the Kubernetes Node's IP when connecting - even if there's only one Node as in the case of Minikube. Port forwarding in Remote - Containers will allow you to specify <ip>:<port>
in either the forwardPorts
property or through the port forwarding UI in VS Code.
Note: This file was auto-generated from the devcontainer-template.json. Add additional notes to a NOTES.md
.