-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfeature.go
More file actions
98 lines (87 loc) · 4.57 KB
/
feature.go
File metadata and controls
98 lines (87 loc) · 4.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package feature
import (
"strconv"
extensionscontroller "github.com/gardener/gardener/extensions/pkg/controller"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/component-base/featuregate"
)
const (
// Every feature gate should add a method here following this template:
//
// // MyFeature enables Foo.
// MyFeature featuregate.Feature = "MyFeature"
// MutateDisableNTP enables the mutation that disables NTP if any worker's flatcar image version is greater than or eqaul to `FlatcarImageVersion`
MutateDisableNTP featuregate.Feature = "MutateDisableNTP"
// EnsureSTACKITLBDeletion enables the STACKIT LB deletion cleanup. The function checks for dangling/zombied LB's and then tries to delete them.
EnsureSTACKITLBDeletion featuregate.Feature = "EnsureSTACKITLBDeletion"
// UseSTACKITAPIInfrastructureController Uses the STACKIT API to create the shoot resources instead of OpenStack.
UseSTACKITAPIInfrastructureController featuregate.Feature = "UseSTACKITAPIInfrastructureController"
// UseSTACKITMachineControllerManager Uses the STACKIT machine controller Manager to manage nodes.
UseSTACKITMachineControllerManager featuregate.Feature = "UseSTACKITMachineControllerManager"
// STACKITApplicationLoadBalancerControllerManager Enables the STACKIT ALP controller manager.
STACKITApplicationLoadBalancerControllerManager featuregate.Feature = "STACKITApplicationLoadBalancerControllerManager"
// ShootUseSTACKITMachineControllerManager Uses the STACKIT machine controller Manager to manage nodes for a specific Shoot.
ShootUseSTACKITMachineControllerManager = "shoot.gardener.cloud/use-stackit-machine-controller-manager"
// ShootUseSTACKITAPIInfrastructureController Uses the STACKIT API to create the shoot resources instead of OpenStack for a specific Shoot.
ShootUseSTACKITAPIInfrastructureController = "shoot.gardener.cloud/use-stackit-api-infrastructure-controller"
// ShootSTACKITApplicationLoadBalancerControllerManager Enables the STACKIT ALP controller manager for a specific Shoot.
ShootSTACKITApplicationLoadBalancerControllerManager = "shoot.gardener.cloud/stackit-application-load-balancer-controller-manager"
)
var (
// MutableGate is the central feature gate map for the gardener-extension-provider-stackit that can be
// mutated. It is automatically initialized with all known features.
// Use this only if you need to set the feature enablement state (i.e., in
// the entrypoint or in tests). For determining whether a feature
// gate is enabled, use Gate instead.
MutableGate = featuregate.NewFeatureGate()
// Gate is the central feature gate map.
// Use this for checking if a feature is enabled, e.g.:
// if feature.Gate.Enabled(feature.MyFeature) { ... }
Gate featuregate.FeatureGate = MutableGate
allGates = map[featuregate.Feature]featuregate.FeatureSpec{
MutateDisableNTP: {Default: true, PreRelease: featuregate.Alpha},
EnsureSTACKITLBDeletion: {Default: true, PreRelease: featuregate.Alpha},
UseSTACKITAPIInfrastructureController: {Default: true, PreRelease: featuregate.Alpha},
UseSTACKITMachineControllerManager: {Default: true, PreRelease: featuregate.Alpha},
STACKITApplicationLoadBalancerControllerManager: {Default: false, PreRelease: featuregate.Alpha},
}
)
func init() {
utilruntime.Must(MutableGate.Add(allGates))
}
func UseStackitMachineControllerManager(cluster *extensionscontroller.Cluster) bool {
if cluster != nil && cluster.Shoot != nil {
annotation, ok := cluster.Shoot.Annotations[ShootUseSTACKITMachineControllerManager]
if ok {
enabledByAnnotation, err := strconv.ParseBool(annotation)
if err == nil {
return enabledByAnnotation
}
}
}
return Gate.Enabled(UseSTACKITMachineControllerManager)
}
func UseStackitAPIInfrastructureController(cluster *extensionscontroller.Cluster) bool {
if cluster != nil && cluster.Shoot != nil {
annotation, ok := cluster.Shoot.Annotations[ShootUseSTACKITAPIInfrastructureController]
if ok {
enabledByAnnotation, err := strconv.ParseBool(annotation)
if err == nil {
return enabledByAnnotation
}
}
}
return Gate.Enabled(UseSTACKITAPIInfrastructureController)
}
func StackitApplicationLoadBalancerControllerManager(cluster *extensionscontroller.Cluster) bool {
if cluster != nil && cluster.Shoot != nil {
annotation, ok := cluster.Shoot.Annotations[ShootSTACKITApplicationLoadBalancerControllerManager]
if ok {
enabledByAnnotation, err := strconv.ParseBool(annotation)
if err == nil {
return enabledByAnnotation
}
}
}
return Gate.Enabled(STACKITApplicationLoadBalancerControllerManager)
}