Skip to content

Add support for multiple namespaces #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

blink-so[bot]
Copy link

@blink-so blink-so bot commented Jun 3, 2025

This PR addresses issue #5 by adding support for watching pods across multiple namespaces.

Changes

Core Functionality

  • Multi-namespace support: CODER_NAMESPACE now accepts comma-separated list of namespaces
  • All-namespace support: Empty CODER_NAMESPACE watches all namespaces cluster-wide
  • Backward compatibility: Single namespace deployments continue to work unchanged

RBAC Improvements

  • Smart RBAC: Automatically uses ClusterRole/ClusterRoleBinding for multi-namespace scenarios
  • Namespace-scoped: Uses Role/RoleBinding for single namespace deployments
  • Configurable: rbac.clusterWide option for manual override

Helm Chart Updates

  • New values: namespaces parameter replaces namespace (backward compatible)
  • Automatic detection: Chart determines RBAC scope based on namespace configuration
  • Documentation: Comprehensive examples for all use cases

Documentation

  • Updated README: Clear examples for single, multiple, and all-namespace deployments
  • RBAC guide: Explains permission requirements for different scenarios
  • Migration guide: Smooth transition from single to multi-namespace setups

Usage Examples

Single namespace (existing behavior):

helm install coder-logstream-kube coder-logstream-kube/coder-logstream-kube \
    --set url=https://coder.example.com \
    --set namespaces="coder-workspaces"

Multiple namespaces:

helm install coder-logstream-kube coder-logstream-kube/coder-logstream-kube \
    --set url=https://coder.example.com \
    --set namespaces="user1,user2,user3"

All namespaces:

helm install coder-logstream-kube coder-logstream-kube/coder-logstream-kube \
    --set url=https://coder.example.com \
    --set namespaces=""

Testing

  • Code compiles successfully
  • Maintains backward compatibility
  • Added unit tests for namespace parsing logic

Fixes #5

blink-so bot added 2 commits June 3, 2025 14:31
- Allow CODER_NAMESPACE to accept comma-separated list of namespaces
- Support watching all namespaces when CODER_NAMESPACE is empty
- Automatically use ClusterRole/ClusterRoleBinding for multi-namespace or all-namespace scenarios
- Update Helm chart to support both namespace-scoped and cluster-wide RBAC
- Add comprehensive documentation for multi-namespace usage
- Maintain backward compatibility with single namespace deployments

Fixes #5
@uvishere
Copy link

Hello,
Any update on this PR? This is a much-awaited feature for us, so any news on this would be good :)

blink-so bot and others added 3 commits June 10, 2025 01:42
- Replace deprecated AgentLogWriter with agentsdk.Client and PatchLogs
- Fix struct field names in tests (namespace -> namespaces)
- Add missing isEmpty method to tokenCache
- Update setPodToken and setReplicaSetToken to return values
- Fix agentLog struct literals in tests
- Add PatchLogs endpoint to fake API for tests
- Update test expectations to match current log message format

Co-authored-by: kylecarbs <7122116+kylecarbs@users.noreply.github.com>
- Add proper context management to logger goroutines
- Fix log level conversion in fake API PatchLogs method
- Improve goroutine lifecycle with cancellation support
- Use ticker-based approach for more reliable log sending
- Continue on PatchLogs errors instead of exiting goroutine

Co-authored-by: kylecarbs <7122116+kylecarbs@users.noreply.github.com>
- Fix Test_logQueuer to use real clock and proper timing
- Add clock advances and sleeps to handle async log processing
- Improve test reliability for TestPodEvents and TestReplicaSetEvents
- Use quartz.NewTicker for proper mock clock integration
- Simplify test expectations for better CI compatibility

Co-authored-by: kylecarbs <7122116+kylecarbs@users.noreply.github.com>
@matifali matifali requested a review from ericpaulsen June 10, 2025 08:41
@matifali
Copy link
Member

cc: @ericpaulsen

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.

Don't limit CODER_NAMESPACE to a single namespace
2 participants