Skip to content

Conversation

@wei840222
Copy link

@wei840222 wei840222 commented Oct 13, 2025

#128

This PR introduces two key enhancements to the cloudflared connector management:

🚀 Features

1. HPA (Horizontal Pod Autoscaler) Support

  • Flexible replica management: When CLOUDFLARED_REPLICA_COUNT < 0, the controller will not modify deployment replicas
  • HPA compatibility: Allows users to configure autoscaling using HPA without controller interference
  • Backward compatibility: Existing configurations continue to work as expected

2. Resource Requirements Management

  • Dynamic resource configuration: Add support for CLOUDFLARED_RESOURCES environment variable
  • JSON-based configuration: Configure CPU/memory limits and requests via JSON format
  • Runtime resource updates: Controller detects and applies resource changes automatically

3. Code Quality Improvements

  • Remove duplicate code: Replace custom slicesEqual function with Go's built-in slices.Equal
  • Better command handling: Rename buildCloudflaredCommand to getCloudflaredCommand for clarity
  • Enhanced error handling: Improved error management and code structure
  • Null safety: Add proper nil checks for replica counts

🔧 Technical Changes

Files Modified:

  • pkg/controller/controlled-cloudflared-connector.go: Core logic enhancements
  • pkg/controller/controlled-cloudflared-connector_test.go: Updated tests and removed obsolete test cases

Key Improvements:

  1. Deployment Logic Refactoring: Streamlined deployment creation and update logic
  2. Resource Detection: Added automatic detection of resource requirement changes
  3. Command Comparison: Enhanced command argument change detection
  4. Memory Management: Better handling of deployment specifications

📋 Usage Examples

Enable HPA support:

env:
  - name: CLOUDFLARED_REPLICA_COUNT
    value: "-1"  # Disable replica management

Configure resources:

env:
  - name: CLOUDFLARED_RESOURCES
    value: '{"requests":{"cpu":"100m","memory":"128Mi"},"limits":{"cpu":"500m","memory":"512Mi"}}'

This enhancement provides more flexibility for users who want to manage cloudflared deployments with advanced Kubernetes features while maintaining simplicity for basic use cases.

…unction

CLOUDFLARED_REPLICA_COUNT < 0, controller will not modify deployment repilcas. It's for user can using HPA to config autoscaling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant