- Learn how DevPod integrates with CKS to create development environments.
- Set up DevPod on CKS using either:
- Basic setup without Docker: A basic development environment without Docker, suitable for most development tasks.
- Advanced setup with Docker: A development environment with Docker support, enabling containerized development.
- Access and verify your development environment using both SSH and web-based interfaces.
- Understand how to manage and clean up DevPod workspaces.
What you'll need
Before you start, you must have:
- A CKS cluster with available CPU or GPU resources.
kubectlinstalled and configured to access your CKS cluster.- A Virtual Server with access to your CKS cluster.
- DevPod CLI installed on your Virtual Server.
What you'll use
You’ll use these tools and technologies:
- DevPod CLI: For creating and managing development environments.
- Kubernetes Pod manifests: For defining your development environment configuration.
- PyTorch container image: As the base development environment.
- Docker-in-Docker (DinD): For Docker-enabled environments (advanced setup).
- VS Code: For development (either the browser-based or the desktop version).
Know before you go
Key concepts
- DevPod: A tool that creates development environments as Kubernetes Pods so you can develop directly on your CKS cluster resources.
- Pod manifest template: A Kubernetes Pod specification that DevPod uses to create your development environment.
- Docker-in-Docker (DinD): A sidecar container that provides Docker functionality within your development environment.
The DevPod CLI assumes that
kubectl is in your PATH, and that the kubectl context is set to the cluster you want to use.Environment setup and assumptions
- SUNK environment: The examples in this tutorial assume a SUNK environment for toleration specification. If you aren’t using a SUNK environment, adjust the toleration specification accordingly.
- PyTorch base image: You use a PyTorch image as the base image, regardless of whether you’re using CPU or GPU resources.
- Namespace organization: Use the
devpodnamespace to keep your DevPod environments organized. This is the default namespace for the Kubernetes provider in DevPod.
Install the DevPod CLI
Install the DevPod CLI on your Virtual Server by following the DevPod installation guide. The DevPod CLI must be installed and running on a Virtual Server that has access to your CKS cluster, because DevPod uses the localkubectl context to provision Pods.
Select a setup path
With the CLI installed, choose the configuration that matches your development needs:- Basic setup without Docker: A basic development environment without Docker, suitable for most development tasks.
- Advanced setup with Docker: A development environment with Docker support, enabling containerized development.
Basic setup without Docker
If your development environment doesn’t require Docker, use this configuration.1. Create the configuration files
First, create a directory for your DevPod configuration files. Then, create the following example configuration files:pod_manifest_template.yaml: A Kubernetes Pod manifest that DevPod uses as a template to provision your development environment.run_demo_gpu_cwsa.sh: A script that creates and starts your DevPod environment..devcontainer/devcontainer.json: A configuration file for the DevContainer IDE.
~/devpod-gpu-sidecar/.
Create the Pod manifest template
Create a file namedpod_manifest_template.yaml with the following content:
pod_manifest_template.yaml
- The
pod_manifest_template.yamlfile defines a Kubernetes Pod manifest that DevPod uses as a template to provision your development environment. - The Pod is created in the
devpodnamespace to keep DevPod resources logically separated from other workloads. - The manifest specifies tolerations for both
sunk.coreweave.com/nodesandis_cpu_computeNode labels so the Pod can be scheduled on Nodes with these taints. - The primary container uses the
pytorch/pytorch:2.4.1-cuda12.4-cudnn9-runtimeimage, mounts a sharedemptyDirvolume at/shared, and runs in a privileged security context to enable advanced development workflows that require elevated permissions.
Create the setup script
Next, create a file namedrun_demo_gpu_cwsa.sh with the following content:
run_demo_gpu_cwsa.sh
Create the .devcontainer configuration
Create a .devcontainer directory, then add a devcontainer.json file with the following content:
.devcontainer/devcontainer.json
2. Start the DevPod environment
Run the setup script to start your DevPod environment:Ctrl+C. Remove the debug flag in the script after you’ve verified that the setup works properly.
Monitor the Pod status to ensure the container is ready:
3. Access your DevPod environment
Open another terminal in your Virtual Server, then list your DevPod workspaces usingdevpod ls:
devpod ssh:
IDE accessWhen you run
devpod ssh, DevPod automatically opens a browser-based VS Code IDE in your Virtual Server’s browser. This happens because the workspace is configured to use openvscode as the IDE (as shown in the devpod ls output).If the browser-based IDE doesn’t open automatically:- Ensure your Virtual Server has a browser installed and accessible.
- Check that the DevPod workspace runs properly.
- You can also access the IDE manually by running
devpod openin a separate terminal.
4. Verify GPU access
Because PyTorch is the base image,nvidia-smi works on GPU systems. Use this to verify GPU access:
Advanced setup with Docker
If your development environment requires Docker, use this advanced configuration, which includes a Docker-in-Docker (DinD) sidecar container.1. Create the Docker-enabled configuration files
Create the Pod manifest template with Docker sidecar
Create a file namedpod_manifest_template.yaml with the following content:
pod_manifest_template.yaml
- The
pod_manifest_template.yamlfile defines a Kubernetes Pod manifest that DevPod uses as a template to provision your development environment. - The Pod is created in the
devpodnamespace to keep DevPod resources logically separated from other workloads. - The manifest specifies tolerations for both
sunk.coreweave.com/nodesandis_cpu_computeNode labels so the Pod can be scheduled on Nodes with these taints. - The primary container uses the
pytorch/pytorch:2.4.1-cuda12.4-cudnn9-runtimeimage, mounts a sharedemptyDirvolume at/shared, and runs in a privileged security context to enable advanced development workflows that require elevated permissions. - The manifest configures a Docker-in-Docker (DinD) sidecar container (
containers.dind) so the primary container can run Docker commands inside the Pod. - The DinD container exposes the Docker daemon on
tcp://0.0.0.0:2375without TLS and disables Docker’s default TLS certificate directory for easier local development. - The
devpodcontainer sets theDOCKER_HOSTenvironment variable to connect to the DinD sidecar, which enables Docker CLI usage. - Both containers mount a shared workspace volume (
devpod) so files can be accessed between the DinD and primary containers. - The manifest uses
emptyDirvolumes for both Docker storage and shared tools to provide ephemeral, fast local storage within the Pod. - Both containers run in privileged mode, which is required for Docker-in-Docker and some advanced development workflows, but should be used with caution in production environments.
Create the setup script with Docker
Create a file namedrun_demo_gpu_cwsa.sh with the following content:
run_demo_gpu_cwsa.sh
Create the devcontainer configuration
Create a.devcontainer directory, then add a devcontainer.json file:
.devcontainer/devcontainer.json
2. Start the DevPod environment with Docker
Run the setup script to start your DevPod environment:Ctrl+C. After you’ve verified that the setup works properly, remove the debug flag from the script.
Monitor the Pod status to ensure both containers are ready:
3. Access your DevPod environment
Open another terminal in your Virtual Server, then list your DevPod workspaces usingdevpod ls:
devpod ssh:
IDE accessWhen you run
devpod ssh, DevPod automatically opens a browser-based VS Code IDE in your Virtual Server’s browser. This happens because the workspace is configured to use openvscode as the IDE (as shown in the devpod ls output).If the browser-based IDE doesn’t open automatically:- Ensure your Virtual Server has a browser installed and accessible.
- Check that the DevPod workspace runs properly.
- You can also access the IDE manually by running
devpod openin a separate terminal.
4. Install Docker CLI
Useapt to install the Docker CLI that connects to the Docker sidecar. This is required to run Docker commands from the primary container.
5. Verify Docker connection
Test that Docker works and connects to the sidecar container by runningdocker ps:
docker run hello-world:
6. Verify GPU access
Because PyTorch is the base image,nvidia-smi should work on GPU systems. Run nvidia-smi to verify GPU access:
Install full Docker with buildx support
If you need multi-platform image builds or other features beyond the basicdocker.io package, install the full Docker Engine with buildx support. Follow the official Docker installation steps:
Update the package index:
Use the full VS Code IDE
If you prefer the desktop VS Code application over the browser-basedopenvscode IDE, you can switch the DevPod workspace to use it. To use the full VS Code IDE for either setup path, first ensure VS Code is installed on the same local client that starts the DevPod. Then, modify your run_demo_gpu_cwsa.sh file to include the following changes for either setup path.
run_demo_gpu_cwsa.sh
devpod open.
Clean up
When you’re finished with your DevPod environment, remove it to free cluster resources. Delete the workspace usingdevpod delete:
kubectl delete namespace: