Using the DevContainer for K8TRE Development
K8TRE now provides a Visual Studio Code DevContainer configuration to simplify setup of development environments. This guide explains how to use this feature.
What is a DevContainer?
A Development Container (DevContainer) defines a consistent, reproducible development environment with all tools and dependencies pre-configured. This eliminates "works on my machine" issues and speeds up onboarding for new contributors.
Prerequisites
To use the DevContainer, you'll need:
- Visual Studio Code installed on your computer
- Docker Desktop (or compatible container runtime)
- Visual Studio Code Remote - Containers extension
Using the DevContainer
-
Clone the K8TRE repository:
-
Open the folder in Visual Studio Code:
-
When prompted, click "Reopen in Container", or use the Command Palette (F1) and select "Remote-Containers: Reopen in Container".
-
VS Code will build the DevContainer (this may take several minutes on the first run).
-
Once the container is ready, you'll have access to:
- All required CLI tools (kubectl, kustomize, helm, argocd, etc.)
- Proper Python environment with dependencies
- Pre-configured Kubernetes extensions
- K3s for local development
Starting Development
Once inside the container:
- The container is already configured with:
- K3s running for local Kubernetes development
- Kubectl configured with the proper kubeconfig
-
ArgoCD installed and ready to use
-
Apply the K8TRE resources:
-
Access the ArgoCD UI:
- Set up port forwarding to access the ArgoCD UI:
- Open https://localhost:8080 (or more likely https://localhost:8081 - check PORTS tab in VS Code) in your browser
- Get the initial admin password. This is displayed at startup or run the following command.
-
Log in with username: admin and the password retrieved above
-
Follow the regular K8TRE development workflow
GitHub Codespaces
The same DevContainer configuration works with GitHub Codespaces. To use it:
- Go to the K8TRE GitHub repository
- Click the "Code" button
- Select the "Codespaces" tab
- Click "Create codespace on main"
This will create a cloud-based development environment with the same configuration.
Customizing the DevContainer
If you need to customize your development environment, you can modify:
.devcontainer/devcontainer.json
- Main configuration file.devcontainer/post-create.sh
- Script that runs after container creation
See the DevContainer README for more details.