Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"permissions": {
"allow": [
"Bash(git commit:*)",
"Bash(git mv:*)",
"Bash(git checkout:*)",
"Bash(git add:*)",
"Bash(tree:*)",
"Bash(find:*)",
"Bash(grep:*)",
"Bash(go build:*)",
"Bash(go mod tidy:*)",
"Bash(go list:*)",
"Bash(go vet:*)",
"Bash(gofmt:*)",
"WebSearch"
]
},
"extraKnownMarketplaces": {
"datum-claude-code-plugins": {
"source": {
"source": "github",
"repo": "datum-cloud/claude-code-plugins"
}
}
},
"enabledPlugins": {
"datum-platform@datum-claude-code-plugins": true,
"datum-gtm@datum-claude-code-plugins": true
}
}
222 changes: 222 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
# Galactic Development Container

This devcontainer provides a complete development environment for the Galactic multi-cloud networking solution.

## Features

### Languages & Runtimes
- **Go 1.24.2** - For operator, agent, and CNI development
- **Python 3.13** - For the galactic-router

### Kubernetes Tools
- **kubectl** - Kubernetes CLI
- **kind** - Kubernetes in Docker for local clusters
- **kustomize v5.6.0** - Kubernetes configuration management
- **controller-gen v0.18.0** - Code generation for Kubernetes controllers
- **setup-envtest** - Test environment for controller-runtime

### Go Development Tools
- **gopls** - Go language server
- **delve** - Go debugger
- **golangci-lint v2.1.6** - Go linter

### Network Tools
- **iproute2** - Advanced network configuration (ip, ss, etc.)
- **iptables** - Firewall management
- **tcpdump** - Network packet analyzer
- **iputils-ping** - Network connectivity testing
- **net-tools** - Classic network tools (ifconfig, netstat, etc.)
- **dnsutils** - DNS utilities (dig, nslookup)
- **bridge-utils** - Bridge configuration
- **ethtool** - Network interface settings
- **conntrack** - Connection tracking

### Build & Development Tools
- **Docker-in-Docker** - For building containers and running Kind clusters
- **protoc 25.1** - Protocol Buffer compiler
- **protoc-gen-go** - Go code generation for protobuf
- **protoc-gen-go-grpc** - gRPC code generation for Go
- **make** - Build automation
- **gcc/build-essential** - C compiler for CGO dependencies
- **jq** - JSON processor
- **git** - Version control

## VS Code Extensions

The devcontainer includes the following extensions:
- **Go** - Official Go extension
- **Python** - Official Python extension
- **Pylance** - Python language server
- **Kubernetes** - Kubernetes resource management
- **YAML** - YAML language support
- **Docker** - Docker container management
- **GitLens** - Enhanced Git integration
- **Markdown Lint** - Markdown linting
- **Even Better TOML** - TOML language support

## Configuration

### Go Settings
- Auto-format on save with `gofmt`
- Organize imports on save
- golangci-lint integration
- gopls with semantic tokens and useful code lenses
- Test environment set to `GOOS=linux`

### Python Settings
- Auto-format on save
- Organize imports on save
- flake8 linting enabled
- Python 3.13 interpreter

### Forwarded Ports
- **8080** - Metrics endpoint
- **8081** - Health check endpoint
- **9443** - Webhook server

## Capabilities

The devcontainer runs with elevated privileges to support network operations:
- `--privileged` - Full device access
- `--cap-add=NET_ADMIN` - Network administration
- `--cap-add=SYS_ADMIN` - System administration

These are required for:
- Creating network namespaces
- Configuring VRFs (Virtual Routing and Forwarding)
- Managing SRv6 routes
- Testing CNI plugins

## Post-Create Setup

The `post-create.sh` script automatically:
1. Installs Go development tools (gopls, delve, golangci-lint)
2. Installs Kubernetes tools (controller-gen, kustomize, setup-envtest, kind)
3. Installs Protocol Buffer compiler and Go plugins
4. Installs network diagnostic tools
5. Sets up the Python environment for galactic-router
6. Generates Kubernetes manifests and DeepCopy methods
7. Configures git safe directory

## Getting Started

After the container starts and post-create completes:

```bash
# Build the galactic binary
make build

# Run unit tests
make test

# Run E2E tests (creates a Kind cluster)
make test-e2e

# Run the operator locally
make run-operator

# Run the agent locally
make run-agent

# Develop the Python router
cd router
behave

# Lint Go code
make lint

# Format Go code
make fmt
```

## Testing

### Unit Tests
```bash
make test
```

### E2E Tests
```bash
# Automatically creates/tears down Kind cluster
make test-e2e

# Or manually manage the cluster
make setup-test-e2e
go test ./test/e2e/ -v -ginkgo.v
make cleanup-test-e2e
```

### Python Tests
```bash
cd router
behave # Run BDD tests
flake8 # Lint Python code
```

## Network Development

The devcontainer includes all tools needed for network programming:

```bash
# View network interfaces
ip link show

# View routing tables
ip route show

# View SRv6 segments
ip -6 route show

# Capture traffic
tcpdump -i any

# Test connectivity
ping -c 3 8.8.8.8
```

## Docker-in-Docker

Build and test containers inside the devcontainer:

```bash
# Build the galactic image
make docker-build

# Create a Kind cluster
kind create cluster --name galactic-dev

# Load image into Kind
kind load docker-image ghcr.io/datum-cloud/galactic:latest --name galactic-dev
```

## Troubleshooting

### Post-create script fails
Check the logs in the VS Code Output panel under "Dev Containers". Common issues:
- Network connectivity for downloading tools
- Permissions for installing system packages

### Network tools don't work
Ensure the container is running with `--privileged` and the necessary capabilities. Check `runArgs` in `devcontainer.json`.

### Kind cluster creation fails
Ensure Docker-in-Docker is running:
```bash
docker ps
```

If not, restart the devcontainer.

### Go modules not resolving
```bash
go mod download
go mod tidy
```

### Python packages not installing
```bash
cd router
pip install --upgrade pip
pip install -e .[test]
```
140 changes: 140 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"name": "galactic",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",
"features": {
"ghcr.io/devcontainers/features/go:1": {
"version": "1.24.2"
},
"ghcr.io/devcontainers/features/python:1": {
"version": "3.13",
"installTools": true
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
"enableNonRootDocker": "true",
"moby": "true"
},
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {
"version": "latest",
"helm": "none",
"minikube": "none"
},
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"installOhMyZsh": true,
"upgradePackages": true,
"username": "vscode",
"userUid": "1000",
"userGid": "1000"
},
"ghcr.io/devcontainers/features/git:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "lts"
}
},
"customizations": {
"vscode": {
"extensions": [
"golang.go",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"redhat.vscode-yaml",
"ms-azuretools.vscode-docker",
"eamodio.gitlens",
"davidanson.vscode-markdownlint",
"tamasfe.even-better-toml"
],
"settings": {
"go.toolsManagement.autoUpdate": true,
"go.useLanguageServer": true,
"go.lintTool": "golangci-lint",
"go.lintFlags": [
"--fast"
],
"go.formatTool": "gofmt",
"go.testEnvVars": {
"GOOS": "linux"
},
"go.buildFlags": [],
"go.testFlags": [
"-v"
],
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"gopls": {
"formatting.gofumpt": true,
"ui.semanticTokens": true,
"ui.codelenses": {
"gc_details": false,
"regenerate_cgo": false,
"generate": true,
"test": true,
"tidy": true,
"upgrade_dependency": true,
"vendor": true
}
},
"python.defaultInterpreterPath": "/usr/local/bin/python3",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.flake8Path": "/usr/local/bin/flake8",
"python.formatting.provider": "none",
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "ms-python.python",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"files.watcherExclude": {
"**/bin/**": true,
"**/dist/**": true,
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/**": true
},
"files.exclude": {
"**/.git": false
},
"terminal.integrated.defaultProfile.linux": "bash"
}
}
},
"forwardPorts": [8080, 8081, 9443],
"portsAttributes": {
"8080": {
"label": "Metrics",
"onAutoForward": "notify"
},
"8081": {
"label": "Health",
"onAutoForward": "notify"
},
"9443": {
"label": "Webhook",
"onAutoForward": "notify"
}
},
"remoteUser": "vscode",
"containerEnv": {
"GOOS": "linux",
"CGO_ENABLED": "1"
},
"mounts": [
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached"
],
"postCreateCommand": "bash .devcontainer/post-create.sh",
"runArgs": [
"--privileged",
"--cap-add=NET_ADMIN",
"--cap-add=SYS_ADMIN"
]
}
Loading