-
Notifications
You must be signed in to change notification settings - Fork 283
✨ Add PriorityQueue feature flag #2823
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
docs/book/src/experimental-features/experimental-features.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # Experimental Features | ||
|
|
||
| CAPO now ships with experimental features the users can enable. | ||
|
|
||
| Currently CAPO has the following experimental features: | ||
| * `PriorityQueue` (env var: `EXP_CAPO_PRIORITY_QUEUE`): [PriorityQueue](./priority-queue.md) | ||
|
|
||
| ## Enabling Experimental Features for Management Clusters Started with clusterctl | ||
|
|
||
| Users can enable/disable features by setting OS environment variables before running `clusterctl init`, e.g.: | ||
|
|
||
| ```yaml | ||
| export EXP_SOME_FEATURE_NAME=true | ||
|
|
||
| clusterctl init --infrastructure openstack | ||
| ``` | ||
|
|
||
| As an alternative to environment variables, it is also possible to set variables in the clusterctl config file located at `$XDG_CONFIG_HOME/cluster-api/clusterctl.yaml`, e.g.: | ||
| ```yaml | ||
| # Values for environment variable substitution | ||
| EXP_SOME_FEATURE_NAME: "true" | ||
| ``` | ||
| In case a variable is defined in both the config file and as an OS environment variable, the environment variable takes precedence. | ||
| For more information on how to set variables for clusterctl, see [clusterctl Configuration File](https://cluster-api.sigs.k8s.io/clusterctl/configuration) | ||
|
|
||
|
|
||
| ## Enabling Experimental Features on Existing Management Clusters | ||
|
|
||
| To enable/disable features on existing management clusters, users can edit the controller manager | ||
| deployments, which will then trigger a restart with the requested features. E.g: | ||
|
|
||
| ``` | ||
| kubectl edit -n capo-system deployment.apps/capo-controller-manager | ||
| ``` | ||
| ``` | ||
| // Enable/disable available features by modifying Args below. | ||
| spec: | ||
| template: | ||
| spec: | ||
| containers: | ||
| - args: | ||
| - --leader-elect | ||
| - --feature-gates=SomeFeature=true,OtherFeature=false | ||
| ``` | ||
|
|
||
| Similarly, to **validate** if a particular feature is enabled, see the arguments by issuing: | ||
|
|
||
| ```bash | ||
| kubectl describe -n capo-system deployment.apps/capo-controller-manager | ||
| ``` | ||
|
|
||
| ## Enabling Experimental Features for e2e Tests | ||
|
|
||
| Features can be enabled by setting them as environmental variables before running e2e tests. | ||
|
|
||
| For `ci` this can also be done through updating `./test/e2e/data/e2e_conf.yaml`. | ||
|
|
||
| ## Enabling Experimental Features on Tilt | ||
|
|
||
| On development environments started with `Tilt`, features can be enabled by setting the feature variables in `kustomize_substitutions`, e.g.: | ||
|
|
||
| ```yaml | ||
| kustomize_substitutions: | ||
| EXP_CAPO_PRIORITY_QUEUE: 'true' | ||
| ``` | ||
|
|
||
| For more details on setting up a development environment with `tilt`, see [Developing with Tilt](../development/development.md#developing-with-tilt) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Priority Queue | ||
|
|
||
| > **Note:** PriorityQueue is available in >= 0.14 | ||
| The `PriorityQueue` feature flag enables the usage of the controller-runtime PriorityQueue. | ||
|
|
||
| This feature deprioritizes reconciliation of objects that were not edge-triggered (i.e. due to an create/update etc.) and makes the controller more responsive during full resyncs and controller startups. | ||
|
|
||
| More information on controller-runtime PriorityQueue: | ||
| - [release-notes](https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.20.0) | ||
| - [design docs](https://github.com/kubernetes-sigs/controller-runtime/pull/3013) | ||
| - [tracking issue](https://github.com/kubernetes-sigs/controller-runtime/issues/2374) | ||
|
|
||
| ## Enabling Priority Queue | ||
|
|
||
| You can enable `PriorityQueue` using the following. | ||
|
|
||
| - Environment variable: `EXP_CAPO_PRIORITY_QUEUE=true` | ||
| - clusterctl.yaml variable: `EXP_CAPO_PRIORITY_QUEUE: true` | ||
| - --feature-gates argument: `PriorityQueue=true` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| Copyright 2022 The Kubernetes Authors. | ||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| // Package feature handles feature gates. | ||
| package feature | ||
|
|
||
| import ( | ||
| "k8s.io/apimachinery/pkg/util/runtime" | ||
| "k8s.io/component-base/featuregate" | ||
| ) | ||
|
|
||
| const ( | ||
| // Every capo-specific feature gate should add method here following this template: | ||
| // | ||
| // // owner: @username | ||
| // // alpha: v1.X | ||
| // MyFeature featuregate.Feature = "MyFeature". | ||
|
|
||
| // PriorityQueue is a feature gate that controls if the controller uses the controller-runtime PriorityQueue | ||
| // instead of the default queue implementation. | ||
| // | ||
| // alpha: v0.14 | ||
| PriorityQueue featuregate.Feature = "PriorityQueue" | ||
| ) | ||
|
|
||
| func init() { | ||
| runtime.Must(MutableGates.Add(defaultCAPOFeatureGates)) | ||
| } | ||
|
|
||
| // defaultCAPOFeatureGates consists of all known capo-specific feature keys. | ||
| // To add a new feature, define a key for it above and add it here. | ||
| var defaultCAPOFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{ | ||
| // Every feature should be initiated here: | ||
| PriorityQueue: {Default: false, PreRelease: featuregate.Alpha}, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| Copyright 2022 The Kubernetes Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package feature | ||
|
|
||
| import ( | ||
| "k8s.io/component-base/featuregate" | ||
| ) | ||
|
|
||
| var ( | ||
| // MutableGates is a mutable version of DefaultFeatureGate. | ||
| // Only top-level commands/options setup and the k8s.io/component-base/featuregate/testing package should make use of this. | ||
| // Tests that need to modify featuregate gates for the duration of their test should use: | ||
| // defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.<FeatureName>, <value>)() | ||
| MutableGates = featuregate.NewFeatureGate() | ||
|
|
||
| // Gates is a shared global FeatureGate. | ||
| // Top-level commands/options setup that needs to modify this featuregate gate should use DefaultMutableFeatureGate. | ||
| Gates featuregate.FeatureGate = MutableGates | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some notes about this:
EXP_CAPO_PRIORITY_QUEUEto differentiate from capiEXP_PRIORITY_QUEUE, not sure if this is needed