AUTOSCALE-871: allow Karpenter Operator to run in ManagementCluster mode - #19
AUTOSCALE-871: allow Karpenter Operator to run in ManagementCluster mode#19maxcao13 wants to merge 1 commit into
Conversation
|
Skipping CI for Draft Pull Request. |
|
@maxcao13: This pull request references AUTOSCALE-871 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: maxcao13 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
WalkthroughChangesManagement cluster support
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant Options
participant Operator
participant Controllers
CLI->>Options: Load environment and flags
Options-->>CLI: Validated management-cluster settings
CLI->>Operator: Run(options)
Operator->>Operator: Build infrastructure from environment
Operator->>Controllers: ResolveControllerConfig
Controllers-->>Operator: No controllers for management cluster
🚥 Pre-merge checks | ✅ 13 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (13 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
cab1f8f to
669c586
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@pkg/operator/options_test.go`:
- Around line 14-17: Update the test around opts.LoadEnv to isolate the
environment contract by setting PLATFORM, REGION, and MANAGEMENT_CLUSTER with
t.Setenv before loading. After LoadEnv succeeds, assert that the corresponding
option fields contain those configured values, preventing ambient environment
values from affecting the test and covering the new fields.
In `@test/suites/operator/operator_test.go`:
- Around line 65-66: Gate the controller-dependent tests in the operator suite
on !env.IsManagementCluster(), including Karpenter reconciliation,
operand-readiness, spec-propagation, and drift-correction contexts. Update the
existing management-cluster skip logic around the ClusterOperator setup so these
assertions do not run when controller construction is suppressed, while
preserving normal-mode coverage.
🪄 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: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 5ef0a368-28cf-42bc-8d70-0f212d729cce
📒 Files selected for processing (12)
cmd/main.gopkg/cloudprovider/aws/consts.gopkg/cloudprovider/aws/provider.gopkg/cloudprovider/common/common.gopkg/cloudprovider/common/consts.gopkg/controllers/controllers.gopkg/controllers/karpenter/controller.gopkg/operator/operator.gopkg/operator/options.gopkg/operator/options_test.gotest/pkg/environment/environment.gotest/suites/operator/operator_test.go
💤 Files with no reviewable changes (1)
- pkg/cloudprovider/common/common.go
🚧 Files skipped from review as they are similar to previous changes (1)
- pkg/controllers/karpenter/controller.go
Allows KarpenterOperator to run in 'ManagementCluster' mode.
This means that when enabled, Karpenter Operator is assumed to run in a management cluster.
Karpenter CRDs will live in a separate guest cluster that the management cluster oversees.
Introduces:
- a new flag to the karpenter-operator binary called 'target-kubeconfig' which is the path to a guest cluster kubeconfig
- an environment variable called MANAGEMENT_CLUSTER is read by karpenter-operator
- if set to 'true', this enables Karpenter Operator to be deployed in management cluster mode
Currently target-kubeconfig is not wired up to any logic. That work is tracked in a separate issue.
As of now, the flag only exists to not break HCP during the refactor which will pass that argument.
Signed-off-by: Max Cao <macao@redhat.com>
669c586 to
792c56c
Compare
| if err != nil { | ||
| return fmt.Errorf("failed to discover infrastructure: %w", err) | ||
| } | ||
| } |
There was a problem hiding this comment.
Re-thinking about this, it is probably better to just remove the discovering infrastructure logic altogether. I was only using it in standalone, but since we are going to use CAPI there is no use for it any longer, and we pass through important fields through env vars and flags on HCP.
|
/retest LGTM, but I don't have enough background in the surrounding components yet to get all the details. Also not sure how the kubeconfig would be provided but that's something I can find out 😀 . |
|
@maxcao13: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Allows KarpenterOperator to run in 'ManagementCluster' mode. This means that when enabled, Karpenter Operator is assumed to run in a management cluster. Karpenter CRDs will live in a separate guest cluster that the management cluster oversees.
Introduces:
Currently target-kubeconfig is not wired up to any logic. That work is tracked in a separate issue. As of now, the flag only exists to not break HCP during the refactor which will pass that argument.
This is part 1 of the effort to allow HCP to deploy Karpenter Operator from this repo. Second part will reference this PR and will be a PR against openshift/hypershift.
Summary by CodeRabbit
New Features
Bug Fixes
Tests