-
Notifications
You must be signed in to change notification settings - Fork 473
/
vpa.go
90 lines (77 loc) · 3.61 KB
/
vpa.go
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
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package botanist
import (
"context"
"k8s.io/utils/ptr"
"github.com/gardener/gardener/imagevector"
v1beta1constants "github.com/gardener/gardener/pkg/apis/core/v1beta1/constants"
"github.com/gardener/gardener/pkg/component"
"github.com/gardener/gardener/pkg/component/autoscaling/vpa"
imagevectorutils "github.com/gardener/gardener/pkg/utils/imagevector"
)
// DefaultVerticalPodAutoscaler returns a deployer for the Kubernetes Vertical Pod Autoscaler.
func (b *Botanist) DefaultVerticalPodAutoscaler() (vpa.Interface, error) {
imageAdmissionController, err := imagevector.ImageVector().FindImage(imagevector.ImageNameVpaAdmissionController, imagevectorutils.RuntimeVersion(b.SeedVersion()), imagevectorutils.TargetVersion(b.ShootVersion()))
if err != nil {
return nil, err
}
imageRecommender, err := imagevector.ImageVector().FindImage(imagevector.ImageNameVpaRecommender, imagevectorutils.RuntimeVersion(b.SeedVersion()), imagevectorutils.TargetVersion(b.ShootVersion()))
if err != nil {
return nil, err
}
imageUpdater, err := imagevector.ImageVector().FindImage(imagevector.ImageNameVpaUpdater, imagevectorutils.RuntimeVersion(b.SeedVersion()), imagevectorutils.TargetVersion(b.ShootVersion()))
if err != nil {
return nil, err
}
var (
valuesAdmissionController = vpa.ValuesAdmissionController{
Image: imageAdmissionController.String(),
PriorityClassName: v1beta1constants.PriorityClassNameShootControlPlane200,
Replicas: ptr.To(b.Shoot.GetReplicas(1)),
TopologyAwareRoutingEnabled: b.Shoot.TopologyAwareRoutingEnabled,
}
valuesRecommender = vpa.ValuesRecommender{
Image: imageRecommender.String(),
PriorityClassName: v1beta1constants.PriorityClassNameShootControlPlane200,
Replicas: ptr.To(b.Shoot.GetReplicas(1)),
}
valuesUpdater = vpa.ValuesUpdater{
Image: imageUpdater.String(),
PriorityClassName: v1beta1constants.PriorityClassNameShootControlPlane200,
Replicas: ptr.To(b.Shoot.GetReplicas(1)),
}
)
if vpaConfig := b.Shoot.GetInfo().Spec.Kubernetes.VerticalPodAutoscaler; vpaConfig != nil {
valuesRecommender.Interval = vpaConfig.RecommenderInterval
valuesRecommender.RecommendationMarginFraction = vpaConfig.RecommendationMarginFraction
valuesRecommender.TargetCPUPercentile = vpaConfig.TargetCPUPercentile
valuesUpdater.EvictAfterOOMThreshold = vpaConfig.EvictAfterOOMThreshold
valuesUpdater.EvictionRateBurst = vpaConfig.EvictionRateBurst
valuesUpdater.EvictionRateLimit = vpaConfig.EvictionRateLimit
valuesUpdater.EvictionTolerance = vpaConfig.EvictionTolerance
valuesUpdater.Interval = vpaConfig.UpdaterInterval
}
return vpa.New(
b.SeedClientSet.Client(),
b.Shoot.SeedNamespace,
b.SecretsManager,
vpa.Values{
ClusterType: component.ClusterTypeShoot,
Enabled: true,
SecretNameServerCA: v1beta1constants.SecretNameCACluster,
RuntimeKubernetesVersion: b.Seed.KubernetesVersion,
AdmissionController: valuesAdmissionController,
Recommender: valuesRecommender,
Updater: valuesUpdater,
},
), nil
}
// DeployVerticalPodAutoscaler deploys or destroys the VPA to the shoot namespace in the seed.
func (b *Botanist) DeployVerticalPodAutoscaler(ctx context.Context) error {
if !b.Shoot.WantsVerticalPodAutoscaler {
return b.Shoot.Components.ControlPlane.VerticalPodAutoscaler.Destroy(ctx)
}
return b.Shoot.Components.ControlPlane.VerticalPodAutoscaler.Deploy(ctx)
}