feat: add out-of-cluster platform-connector deployment mode#1359
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR enables Platform Connectors to authenticate to Kubernetes using explicit kubeconfig files. A kubeconfig loader was added, the Kubernetes connector and metadata transformer use it, pipeline factory API accepts options carrying kubeconfig path, main CLI wires a -kubeconfig flag, and docs/tests updated. ChangesOut-of-Cluster Kubernetes Authentication
Sequence Diagram(s): sequenceDiagram
participant CLI as CLI Flags
participant Run as run()
participant Init as initializeConnectors / initializePipeline
participant K8s as InitializeK8sConnector
participant Loader as kubeconfig.Load
participant Pipeline as pipeline.NewFromConfigs
CLI->>Run: provide `--kubeconfig` (or empty)
Run->>Run: log auth mode
Run->>Init: pass kubeconfigPath
Init->>K8s: initializeK8sConnector(kubeconfigPath)
K8s->>Loader: kubeconfig.Load(kubeconfigPath)
Run->>Pipeline: NewFromConfigs(..., Options{KubeconfigPath})
Pipeline->>Loader: kubeconfig.Load(opts.KubeconfigPath) (in transformers)
Estimated code review effort:
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
Signed-off-by: sulixu <xc26888@gmail.com>
lalitadithya
left a comment
There was a problem hiding this comment.
Thank you for your PR! Can you also complete the DCO process -- https://github.com/NVIDIA/NVSentinel/pull/1359/checks?check_run_id=79362762538
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
platform-connectors/pkg/connectors/kubernetes/k8s_connector.go (1)
68-71: ⚡ Quick winAdd a doc comment for
InitializeK8sConnector.This exported function now has a public signature change but no leading comment.
Proposed fix
+// InitializeK8sConnector creates a Kubernetes connector and clientset using either +// in-cluster credentials or an explicit kubeconfig path. func InitializeK8sConnector(ctx context.Context, ringbuffer *ringbuffer.RingBuffer, qps float32, burst int, stopCh <-chan struct{}, cfg K8sConnectorConfig, kubeconfigPath string, ) (*K8sConnector, kubernetes.Interface, error) {As per coding guidelines, "Include function comments for exported Go functions".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@platform-connectors/pkg/connectors/kubernetes/k8s_connector.go` around lines 68 - 71, Add a Go doc comment for the exported InitializeK8sConnector function describing its purpose (initializes and returns a K8sConnector and kubernetes.Interface), summarizing key parameters (ctx, ringbuffer *ringbuffer.RingBuffer, qps, burst, stopCh <-chan struct{}, cfg K8sConnectorConfig, kubeconfigPath string) and the return values ( *K8sConnector, kubernetes.Interface, error); ensure the comment sits immediately above the InitializeK8sConnector declaration and follows Go doc conventions (starts with the function name and is a complete sentence).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@platform-connectors/pkg/connectors/kubernetes/k8s_connector.go`:
- Around line 82-85: Wrap the error returned by kubeconfig.Load(kubeconfigPath)
with connector context before returning; replace the bare return of err in the
block that calls kubeconfig.Load with a wrapped error like
fmt.Errorf("kubernetes connector: failed to load kubeconfig %s: %w",
kubeconfigPath, err) (importing fmt if necessary) so the initializer functions
(the block around kubeconfig.Load and its nil, nil, err return) convey
connector-level context.
In `@platform-connectors/pkg/pipeline/factory.go`:
- Around line 25-29: Add Go doc comments for the exported API in this file:
write concise godoc lines above the Options type, Factory type, Register
function, Create function, and NewFromConfigs function describing their purpose
and behaviour (including any important params/returns) so the exported pipeline
contract is documented; reference the types/names Options, Factory, Register,
Create, NewFromConfigs and briefly mention related types used in signatures such
as Transformer and Config to clarify their roles in the comments.
---
Nitpick comments:
In `@platform-connectors/pkg/connectors/kubernetes/k8s_connector.go`:
- Around line 68-71: Add a Go doc comment for the exported
InitializeK8sConnector function describing its purpose (initializes and returns
a K8sConnector and kubernetes.Interface), summarizing key parameters (ctx,
ringbuffer *ringbuffer.RingBuffer, qps, burst, stopCh <-chan struct{}, cfg
K8sConnectorConfig, kubeconfigPath string) and the return values (
*K8sConnector, kubernetes.Interface, error); ensure the comment sits immediately
above the InitializeK8sConnector declaration and follows Go doc conventions
(starts with the function name and is a complete sentence).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: f0ed88b2-3cb7-41b4-aabd-0a1326ee9285
📒 Files selected for processing (12)
docs/configuration/platform-connectors.mddocs/platform-connectors.mdplatform-connectors/main.goplatform-connectors/main_test.goplatform-connectors/pkg/connectors/kubernetes/k8s_connector.goplatform-connectors/pkg/connectors/kubernetes/k8s_connector_init_test.goplatform-connectors/pkg/kubeconfig/loader.goplatform-connectors/pkg/kubeconfig/loader_test.goplatform-connectors/pkg/pipeline/factory.goplatform-connectors/pkg/pipeline/factory_test.goplatform-connectors/pkg/transformers/metadata/factory.goplatform-connectors/pkg/transformers/overrides/factory.go
54c87fa to
1d80810
Compare
Signed-off-by: sulixu <xc26888@gmail.com>
|
/ok to test 41c0e63 |
|
🌿 Fern Docs Preview: https://nvidia-preview-pull-request-1359.docs.buildwithfern.com/nvsentinel |
Summary
Add optional out-of-cluster Kubernetes auth for
platform-connectorsvia--kubeconfig.This threads the kubeconfig path through startup, connector initialization, and pipeline transformer creation so both the Kubernetes connector and
MetadataAugmentoruse the same explicit client config whenplatform-connectorsruns outside the cluster (for example undersystemd). When--kubeconfigis unset, existing in-cluster auth behavior remains unchanged.Also updates docs for the new auth mode and adds unit coverage for flag parsing, kubeconfig loading, connector init, and pipeline option propagation
Type of Change
Component(s) Affected
Testing
Checklist
Summary by CodeRabbit
New Features
Documentation
Tests