Development¶
Guides for contributing to and developing DB Provision Operator.
Overview¶
- Contributing - How to contribute
- Testing - Testing strategies
- CI/CD - Continuous integration and deployment
Quick Start¶
Prerequisites¶
- Go 1.21+
- Docker
- kubectl
- kind or minikube
- Make
Clone and Build¶
# Clone repository
git clone https://github.com/panteparak/db-provision-operator.git
cd db-provision-operator
# Install dependencies
make install-tools
# Build
make build
# Run tests
make test
Local Development¶
Development Workflow¶
- Create feature branch
- Make changes
- Write/update tests
- Run tests locally
- Submit pull request
Project Structure¶
db-provision-operator/
├── api/ # CRD API definitions
│ └── v1alpha1/ # API version
├── cmd/ # Main entrypoints
│ └── main.go # Operator entrypoint
├── config/ # Kubernetes manifests
│ ├── crd/ # CRD definitions
│ ├── manager/ # Operator deployment
│ ├── rbac/ # RBAC rules
│ └── samples/ # Sample resources
├── internal/ # Internal packages
│ ├── controller/ # Controllers
│ ├── database/ # Database adapters
│ └── utils/ # Utilities
├── test/ # Tests
│ ├── e2e/ # End-to-end tests
│ └── fixtures/ # Test fixtures
├── charts/ # Helm charts
│ └── db-provision-operator/
├── docs/ # Documentation
├── DOCS/ # Additional docs and examples
├── Dockerfile # Container image
├── Makefile # Build automation
└── go.mod # Go modules
Key Technologies¶
| Technology | Purpose |
|---|---|
| Kubebuilder | Operator framework |
| controller-runtime | Controller library |
| Ginkgo | Testing framework |
| Gomega | Assertion library |
| envtest | Integration testing |
Makefile Targets¶
# Development
make build # Build binary
make run # Run locally
make install # Install CRDs
make uninstall # Uninstall CRDs
# Testing
make test # Unit tests
make test-e2e # E2E tests
make lint # Run linters
# Docker
make docker-build # Build image
make docker-push # Push image
# Cluster
make kind-create # Create kind cluster
make kind-delete # Delete kind cluster
make deploy # Deploy to cluster
# Documentation
make docs-serve # Serve docs locally
make docs-build # Build docs
Code Generation¶
After modifying API types:
Debugging¶
VS Code Launch Config¶
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Operator",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/main.go",
"env": {
"KUBECONFIG": "${env:HOME}/.kube/config"
}
}
]
}
GoLand/IntelliJ¶
- Run > Edit Configurations
- Add Go Build
- Package path:
./cmd - Environment:
KUBECONFIG=$HOME/.kube/config
Next Steps¶
- Contributing - Contribution guidelines
- Testing - Write and run tests
- CI/CD - Understanding the pipeline