|
| 1 | +/* |
| 2 | +Copyright 2025 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package features |
| 18 | + |
| 19 | +import ( |
| 20 | + "k8s.io/apimachinery/pkg/util/runtime" |
| 21 | + "k8s.io/apimachinery/pkg/util/version" |
| 22 | + "k8s.io/component-base/featuregate" |
| 23 | + |
| 24 | + "k8s.io/autoscaler/vertical-pod-autoscaler/common" |
| 25 | +) |
| 26 | + |
| 27 | +const ( |
| 28 | + // Every feature gate should add method here following this template: |
| 29 | + // |
| 30 | + // // alpha: v1.X |
| 31 | + // // components: admission-controller, recommender, updater |
| 32 | + // |
| 33 | + // MyFeature featuregate.Feature = "MyFeature". |
| 34 | + // |
| 35 | + // Feature gates should be listed in alphabetical, case-sensitive |
| 36 | + // (upper before any lower case character) order. This reduces the risk |
| 37 | + // of code conflicts because changes are more likely to be scattered |
| 38 | + // across the file. |
| 39 | + // |
| 40 | + // In each feature gate description, you must specify "components". |
| 41 | + // The feature must be enabled by the --feature-gates argument on each listed component. |
| 42 | + |
| 43 | + // alpha: v1.4.0 |
| 44 | + // components: admission-controller, updater |
| 45 | + |
| 46 | + // InPlaceOrRecreate enables the InPlaceOrRecreate update mode to be used. |
| 47 | + // Requires KEP-1287 InPlacePodVerticalScaling feature-gate to be enabled on the cluster. |
| 48 | + InPlaceOrRecreate featuregate.Feature = "InPlaceOrRecreate" |
| 49 | +) |
| 50 | + |
| 51 | +// MutableFeatureGate is a mutable, versioned, global FeatureGate. |
| 52 | +var MutableFeatureGate featuregate.MutableVersionedFeatureGate = featuregate.NewFeatureGate() |
| 53 | + |
| 54 | +// Enabled is a helper function for MutableFeatureGate.Enabled(f) |
| 55 | +func Enabled(f featuregate.Feature) bool { |
| 56 | + return MutableFeatureGate.Enabled(f) |
| 57 | +} |
| 58 | + |
| 59 | +func init() { |
| 60 | + // set the emulation version to align with VPA versioning system |
| 61 | + runtime.Must(MutableFeatureGate.SetEmulationVersion(version.MustParse(common.VerticalPodAutoscalerVersion()))) |
| 62 | + runtime.Must(MutableFeatureGate.AddVersioned(defaultVersionedFeatureGates)) |
| 63 | +} |
0 commit comments