Thank you for your interest in contributing to kubectl-reboot! This document provides guidelines and information for contributors.
This project follows the Kubernetes Community Code of Conduct. By participating, you are expected to uphold this code.
- Fork the repository on GitHub
- Clone your fork locally
- Create a feature branch from
main - Make your changes and add tests
- Run tests and linting:
make check - Commit with conventional commit messages
- Push to your fork and submit a Pull Request
- Check existing issues first to avoid duplicates
- Use the bug report template when creating new issues
- Provide detailed information:
- kubectl-reboot version (
kubectl reboot --version) - Kubernetes version (
kubectl version) - Operating system and architecture
- SSH configuration and target node details
- Steps to reproduce the issue
- Expected vs actual behavior
- Complete error messages and logs
- kubectl-reboot version (
- Check existing feature requests first
- Open an issue with the feature request template
- Describe the use case and why the feature would be valuable
- Provide examples of how the feature would be used
- Consider backwards compatibility implications
- Go 1.24 or later
- kubectl installed and configured
- Access to a Kubernetes cluster for testing (kind, minikube, or cloud cluster)
- SSH access to test nodes (for integration testing)
- Git configured with your GitHub account
# Clone your fork
git clone https://github.com/YOUR-USERNAME/kubectl-reboot.git
cd kubectl-reboot
# Add upstream remote
git remote add upstream https://github.com/ayetkin/kubectl-reboot.git
# Install dependencies
go mod download
# Run initial build and tests
make build
make test
make check-
Sync with upstream:
git checkout main git pull upstream main git push origin main
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes:
- Follow existing code patterns
- Add comprehensive tests
- Update documentation
- Test manually with real clusters
-
Validate your changes:
make check # Run all linting and formatting checks make test # Run unit tests make build # Ensure it builds successfully ./bin/kubectl-reboot --help # Test the binary
-
Commit with conventional commit format:
git add . git commit -m "feat: add support for custom drain timeout"
Commit message format:
feat:- New featuresfix:- Bug fixesdocs:- Documentation changestest:- Adding or updating testsrefactor:- Code refactoring without functional changesperf:- Performance improvementsci:- CI/CD related changeschore:- Maintenance and tooling
-
Push and create Pull Request:
git push origin feature/your-feature-name
Go Style:
- Follow standard Go conventions (
go fmt,go vet) - Use meaningful variable and function names
- Keep functions focused and small (< 50 lines when possible)
- Handle all errors appropriately
- Use the existing logging patterns with structured logging
Architecture Principles:
- Separation of Concerns: Keep Kubernetes operations, SSH operations, and business logic separate
- Testability: Write code that can be easily unit tested
- Error Handling: Provide clear, actionable error messages
- Configuration: Use the existing configuration patterns
- Logging: Use structured logging with appropriate levels
Testing:
- Unit Tests: Test individual functions and components
- Integration Tests: Test end-to-end workflows where possible
- Error Scenarios: Test error conditions and edge cases
- Multiple Platforms: Consider platform-specific behavior
Major Features (new commands, significant workflow changes):
- Open an issue first to discuss the design
- Write a design document for complex features
- Break down into smaller PRs when possible
- Update help text and documentation
- Add comprehensive tests
Minor Features (flags, small enhancements):
- Follow existing patterns for similar functionality
- Add appropriate validation
- Update help text
- Add tests
├── cmd/k8s-restart/ # Main application entry point
├── internal/
│ ├── config/ # Configuration management
│ ├── kube/ # Kubernetes client operations
│ └── ssh/ # SSH client operations
├── scripts/ # Build and release scripts
├── .github/workflows/ # CI/CD pipelines
└── docs/ # Additional documentation
- README updates: Keep installation and usage instructions current
- Help text: Update command-line help for new options
- Examples: Add real-world usage examples
- CHANGELOG: Follow Keep a Changelog format
- Code comments: Document complex logic and public APIs
# Run all tests
make test
# Run tests with coverage
go test -cover ./...
# Run specific tests
go test ./internal/config -v
# Run integration tests (requires cluster access)
go test -tags=integration ./test/...- Unit Tests: Fast, isolated tests for individual components
- Integration Tests: Tests that require Kubernetes cluster access
- End-to-End Tests: Full workflow tests with real nodes
- Use table-driven tests for multiple scenarios
- Mock external dependencies (Kubernetes API, SSH connections)
- Test error conditions as well as success paths
- Use descriptive test names that explain what's being tested
- Tests pass:
make checksucceeds - Documentation updated: README, help text, etc.
- Self-review completed: Check your own code for issues
- Commits are clean: Squash fixup commits, use clear messages
- Branch is current: Rebased on latest main
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
## Testing
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review performed
- [ ] Documentation updated
- [ ] Tests added for new functionality
- [ ] All tests pass- Automated checks: CI must pass
- Code review: At least one maintainer review
- Testing: Reviewers may test manually
- Approval: Maintainer approval required for merge
- Merge: Squash and merge preferred
Releases are automated but follow this process:
- Update version in relevant files
- Update CHANGELOG.md with new version
- Create and push tag:
./scripts/release.sh v1.x.x - GitHub Actions handles the rest automatically
- Update Krew index after release is published
# Create a new release
./scripts/release.sh v1.2.3
# Preview what would happen
./scripts/release.sh v1.2.3 --dry-run
# Create draft release for testing
./scripts/release.sh v1.2.3 --draft- Issues: Search existing issues or create new ones
- Discussions: Use GitHub Discussions for questions
- Documentation: Check README and code comments
- Examples: Look at existing tests and usage patterns
Contributors are recognized through:
- Contributors section in README
- Release notes for significant contributions
- GitHub's contributor statistics
- Special thanks in major release announcements
By contributing to kubectl-reboot, you agree that your contributions will be licensed under the project's MIT License.