Thank you for your interest in contributing to the Cluster API Control Plane Provider for Hosted Control Planes! 🎉
We welcome contributions of all kinds - whether you're fixing bugs, adding features, improving documentation, or helping with testing and feedback. This guide will help you get started with the development process.
- 🤝 Code of Conduct
- 🚀 Getting Started
- 🛠️ Development Environment
- 🔄 Development Workflow
- 📏 Code Standards
- 🧪 Testing Guidelines
- 📬 Pull Request Process
- 🐛 Issue Guidelines
- 🏗️ Architecture Overview
- 🚢 Release Process
- ❓ Getting Help
- 🙏 Recognition
This project adheres to a code of conduct that fosters an inclusive and welcoming environment for all contributors. By participating, you are expected to uphold these standards:
- Be Respectful: Treat all contributors with respect and kindness
- Be Collaborative: Work together constructively and give credit where due
- Be Patient: Help newcomers learn and grow
- Be Professional: Focus on technical discussions and avoid personal attacks
Before you begin, ensure you have the following tools installed:
- Go 1.24+: Programming language for the project
- CRI: For container image building and testing (podman, docker, etc.)
- kubectl: Kubernetes CLI tool
- Task: Build automation tool
- Git: Version control
- Telepresence: For local development against remote clusters
- GitHub CLI (gh): For streamlined PR creation
- Cluster API: For integration testing
# Fork the repository on GitHub, then clone your fork
git clone https://github.com/YOUR_USERNAME/cluster-api-provider-hosted-control-plane.git
cd cluster-api-provider-hosted-control-plane
# Add upstream remote
git remote add upstream https://github.com/teutonet/cluster-api-provider-hosted-control-plane.git# Verify Go installation
go version # Should show 1.24+
# Install Task (if not already installed)
# On Archlinux: sudo pacman -S go-task
# recommended to create an alias `alias task=go-task`
# The rest can check https://taskfile.dev/docs/installation
# Verify Task installation
task --versionThe project uses Task for build automation. Here are the most common commands:
# Build the project
task build
# Run tests with coverage
task test
# Run linting (without fixes)
task lint
# Run linting with automatic fixes
task lint fix=true
# Format code
task format
# Generate manifests and code
task generate
task manifests
# Run full CI pipeline (lint + test)
task ci
# Clean build artifacts
task clean# Generate manifests and apply to cluster
task manifests
kubectl apply -f ./build/control-plane-components.yaml
# Start development mode (with telepresence if available)
task dev
# Now run the controller in your IDE using the provided .run configurations# Run controller locally
go run ./cmd/hosted-control-plane-controller/main.go \
--webhook-port=9443 \
--enable-leader-election=false-
Create a Feature Branch
git switch -c feature/your-feature-name
-
Make Your Changes
- Write clear, focused commits
- Follow the project's code standards
- Add tests for new functionality
- Update documentation as needed
-
Test Your Changes
# Run the full CI pipeline task ci # Check for uncommitted generated files task check-diff
-
Commit and Push
git add . git commit -m "feat: add awesome new feature" git push origin feature/your-feature-name
This project follows Conventional Commits for commit messages.
Please use the standard format:
type: description (e.g., feat: add backup scheduling, fix: resolve controller memory leak).
The project enforces strict code standards using golangci-lint with over 70 enabled linters:
- Line Length: Maximum 120 characters (enforced by golines)
- Formatting: Use gofumpt (stricter than gofmt)
- Imports: Must follow specific alias rules (see below)
The project requires specific import aliases. Some key ones:
// Kubernetes Core
import (
corev1 "k8s.io/api/core/v1"
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
kerrors "k8s.io/apimachinery/pkg/util/errors"
)
// Controller Runtime
import (
ctrl "sigs.k8s.io/controller-runtime"
)
// Cluster API
import (
capiv2 "sigs.k8s.io/cluster-api/api/core/v1beta2"
)
// Gateway API
import (
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
)
// Cert Manager
import (
certmanagerv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
)
// Project-specific aliases
import (
errorsUtil "github.com/teutonet/cluster-api-provider-hosted-control-plane/pkg/util/errors"
slices "github.com/samber/lo"
)- Error Handling: All errors must be handled (
errcheck) - Security: Security analysis with
gosec - Performance: Performance-oriented checks (
perfsprint,prealloc) - Correctness: Logic and correctness checks (
govet,staticcheck) - Style: Consistent style enforcement (
revive,gocritic)
Some code is auto-generated. Never edit these files directly:
api/**/zz_generated.deepcopy.go- Generated by controller-genapi/**/zz_generated.conversion.go- Generated by conversion-genbuild/directory contents - Generated manifests
- API Documentation: Keep API type documentation up to date
- Unit Tests:
*_test.gofiles alongside source code - Coverage Target: Aim for reasonable test coverage (run
task testto see current coverage)
# Run all tests with coverage
task test
# Run tests for specific package
go test ./pkg/reconcilers/...
# Run tests with verbose output
go test -v ./...-
Run Full CI Pipeline
task ci
-
Verify No Generated Code Changes
task check-diff
-
Update Documentation if needed
- Clear Title: Use conventional commit format (
feat:,fix:,docs:, etc.) - Focused Changes: Keep PRs focused on a single feature or fix
- Test Coverage: Include tests for new functionality
- Documentation: Update docs for user-facing changes
- Backward Compatibility: Avoid breaking changes when possible
When reporting bugs, please include:
- Environment: Kubernetes version, OS, etc.
- Steps to Reproduce: Clear, step-by-step instructions
- Expected Behavior: What should happen
- Actual Behavior: What actually happens
- Logs: Relevant log output or error messages
- Additional Context: Screenshots, configuration files, etc.
For feature requests, please provide:
- Use Case: Why this feature would be valuable
- Proposed Solution: How you envision it working
- Alternatives: Other solutions you've considered
- Additional Context: Examples, mockups, etc.
├── api/ # API type definitions
│ └── v1alpha1/ # API version v1alpha1
├── cmd/ # Main applications
├── config/ # Kubernetes manifests
├── pkg/ # Library code
│ ├── hostedcontrolplane/ # Main controller
│ ├── operator/ # Operator utilities
│ ├── reconcilers/ # Specialized reconcilers
│ └── util/ # Shared utilities
└── build/ # Generated artifacts
- HostedControlPlane Controller: Main reconciliation logic
- Reconcilers: Specialized controllers for different aspects:
etcd_cluster: ETCD management with backup/restoreapiserverresources: API server deployment and servicescertificates: Certificate management via cert-managerinfrastructure_cluster: Infrastructure cluster setupworkload: Workload cluster components (RBAC, CoreDNS, kube-proxy)kubeconfig: Kubeconfig generationtlsroutes: Gateway API TLS route configuration
- Reconciler Pattern: Use controller-runtime reconciler pattern
- Error Handling: Use the project's error utilities (
errorsUtil) - Tracing: OpenTelemetry integration for observability
- Conditions: Status reporting using CAPI conditions
- API Changes: Update types in
api/*/ - Controller Logic: Add reconciliation logic
- Tests: Add comprehensive test coverage
- Documentation: Update relevant documentation, if necessary
Releases are handled by maintainers, but contributors should be aware of:
- Semantic Versioning: We follow semver (major.minor.patch)
- Release Notes: Breaking changes and their migration are documented
- Backward Compatibility: Breaking changes are rare and well-documented
- GitHub Issues: For bug reports and feature requests
- GitHub Discussions: For questions and community discussion
- Code Review: Maintainers will provide feedback on PRs
We value all contributions and recognize our contributors:
- Contributors: Listed in release notes
- Maintainers: Recognized in project documentation
- Community: Thanks to everyone who helps improve the project
Happy contributing! 🚀