Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
blink-so wants to merge8 commits intomain
base:main
Choose a base branch
Loading
frommulti-namespace-support

Conversation

blink-so[bot]
Copy link

@blink-soblink-sobot commentedJun 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: EmptyCODER_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 replacesnamespace (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

uvishere reacted with heart emoji
blink-sobot added2 commitsJune 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 deploymentsFixes#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-sobotand others added3 commitsJune 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 formatCo-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 goroutineCo-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 compatibilityCo-authored-by: kylecarbs <7122116+kylecarbs@users.noreply.github.com>
@matifali
Copy link
Member

cc:@ericpaulsen

@uvishere
Copy link

Hey amazing people,
Coder administrator here.
Just checking if we're still up for merging this feature? If there's no plan for immediate future, I need to start looking for an alternative.
An update would be appreciated. Thank you :)

@matifalimatifali requested review fromsreya andCopilotJune 19, 2025 07:19
Copy link

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR adds support for watching pods across multiple namespaces (including all namespaces) by treating theCODER_NAMESPACE environment variable or--namespaces flag as a comma-separated list. It also updates RBAC handling to switch between namespace-scoped Roles and cluster-wide ClusterRoles, and revises the Helm chart and documentation accordingly.

  • Renamed the CLI flag from--namespace to--namespaces and updatednewPodEventLogger to accept a list
  • Enhanced Helm chart to auto-detect cluster-wide RBAC based onnamespaces (empty or multiple) or explicit override
  • AddedparseNamespaces unit tests and updated documentation/README examples

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
main.goRenamednamespace tonamespaces and updated Cobra flag and logger invocation
logger_test.goUpdated tests to usenamespaces, added clock advances, and newparseNamespaces tests
helm/values.yamlReplacednamespace withnamespaces, introducedrbac.clusterWide
helm/templates/service.yamlAdded logic for selecting ClusterRole vs Role/RoleBinding and updated ServiceAccount deployment
README.mdDocumented multi-namespace/all-namespace usage and updated badges
Comments suppressed due to low confidence (4)

helm/templates/service.yaml:39

  • Fix the YAML list formatting under 'subjects': ensure both 'kind' and 'name' entries are prefixed with '-' at the same indent level to produce valid YAML.
- kind: ServiceAccount

helm/templates/service.yaml:46

  • [nitpick] Use a consistent resource naming convention by prefixing the namespace-scoped Role name with '{{ .Release.Name }}-' to match the ClusterRole naming pattern.
  name: coder-logstream-kube-role

helm/values.yaml:106

  • [nitpick] Remove or clarify the commented-out legacy securityContext lines to keep the values.yaml file clean and maintainable.
  # readOnlyRootFilesystem: true

helm/templates/service.yaml:1

  • Consider adding unit tests for the Helm template logic that determines whether to create cluster-wide or namespace-scoped RBAC resources based on 'namespaces' and 'rbac.clusterWide'.
{{/*

@@ -41,13 +42,14 @@ func TestReplicaSetEvents(t *testing.T) {
agentURL,err:=url.Parse(api.server.URL)
require.NoError(t,err)
namespace:="test-namespace"
sourceUUID:=agentsdk.ExternalLogSourceID
Copy link
Preview

CopilotAIJun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Remove the unused variable 'sourceUUID' or integrate it into the test; as-is it will cause a compilation error due to being unused.

Suggested change
sourceUUID:=agentsdk.ExternalLogSourceID
// Removed unused variable `sourceUUID` to prevent compilation error.

Copilot uses AI. Check for mistakes.

- Add configurable tickInterval to logQueuer struct- Update Test_logQueuer to use real clock with fast tick interval (10ms)- Update TestPodEvents and TestReplicaSetEvents to use real clock- Replace mock clock advances with real time waits- Fix Test_logQueuer test which now passes consistentlyThe new ticker-based logging implementation requires different timingthan the original synchronous approach. Tests now use fast tickintervals (10ms) with real clocks instead of mock clocks to avoidtiming conflicts.Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
README.md Outdated
Comment on lines 3 to 5
[![discord](https://img.shields.io/discord/747933592273027093?label=discord)](https://discord.gg/coder)
[![release](https://img.shields.io/github/v/tag/coder/coder-logstream-kube)](https://github.com/coder/envbuilder/pkgs/container/coder-logstream-kube)
[![godoc](https://pkg.go.dev/badge/github.com/coder/coder-logstream-kube.svg)](https://pkg.go.dev/github.com/coder/coder-logstream-kube)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Keep godoc and discord, and update the release link to the correct release page.

matifaliand others added2 commitsJune 19, 2025 12:59
- Restore discord and godoc badges in README.md- Fix release link to point to correct repository releases page- Use consistent naming for namespace-scoped Role with release prefix- Clean up commented-out legacy securityContext lines in values.yamlThe sourceUUID variable is actually used in tests so no changes needed there.YAML formatting in service.yaml is already correct.Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@matifalimatifalimatifali left review comments

Copilot code reviewCopilotCopilot left review comments

@ericpaulsenericpaulsenAwaiting requested review from ericpaulsen

@sreyasreyaAwaiting requested review from sreya

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Don't limit CODER_NAMESPACE to a single namespace
2 participants
@uvishere@matifali

[8]ページ先頭

©2009-2025 Movatter.jp