Development Setup¶
Set up your local environment for Language Operator development.
Prerequisites¶
- Go 1.21+ - Download
- Docker - For building images
- kubectl - Kubernetes CLI
- Helm 3.8+ - Package manager
- k3d or kind (optional) - Local Kubernetes cluster
- make - Build automation
Clone the Repository¶
Install Git Hooks¶
Install pre-commit hooks for validation:
This installs hooks that:
- Enforce conventional commit messages
- Validate generated files are staged
- Run basic linting
Development Commands¶
All Go work runs from src/:
Build¶
Test¶
Integration Tests¶
Integration tests run against a real Kubernetes API server via controller-runtime's envtest.
Run Single Test¶
Integration Tests Only¶
Modifying CRD Types¶
After changing types in src/api/v1alpha1/:
cd src
make generate # regenerate zz_generated.deepcopy.go
make helm-crds # regenerate CRD YAMLs and copy to chart/crds/
Important: Always stage generated files together with type changes:
The pre-commit hook enforces this.
Helm Chart Validation¶
Documentation¶
Generate CRD Documentation¶
cd src
make docs # generates src/docs/api-reference.md (local inspection only; CI generates docs/api/reference.md)
Preview Documentation Site¶
# Install MkDocs (one time)
pip install mkdocs-material mkdocs-awesome-pages-plugin
# Serve locally
mkdocs serve
Local Kubernetes Testing¶
Create a k3d Cluster¶
Install the Operator¶
From source:
cd chart
helm install language-operator . \
--create-namespace \
--namespace language-operator \
--set image.tag=dev
Build and Load Images¶
For local development:
# Build operator image
docker build -t language-operator:dev .
# Import into k3d
k3d image import language-operator:dev -c langop-dev
For the model proxy:
Watch Logs¶
Development Workflow¶
-
Create a feature branch
-
Make changes and test
-
Commit with conventional commits
-
Push and create PR
Troubleshooting¶
Tests Fail on CI but Pass Locally¶
- Ensure you've run
make generate && make helm-crds - Check that all generated files are committed
- Verify you're using the same Go version as CI
Integration Tests Fail¶
# Install setup-envtest
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
# Run with verbose output
cd src && go test -tags integration -v ./controllers/...
Pre-commit Hook Fails¶
The hook checks:
- Commit message format
- Generated files are staged with their sources
- No obvious issues in Go code
Read the error message carefully—it will tell you what needs fixing.