-
Notifications
You must be signed in to change notification settings - Fork 300
/
params.go
130 lines (119 loc) · 4.4 KB
/
params.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package scheduler
import (
"context"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/util/intstr"
configv1 "github.com/openshift/api/config/v1"
hyperv1 "github.com/openshift/hypershift/api/v1beta1"
"github.com/openshift/hypershift/control-plane-operator/controllers/hostedcontrolplane/imageprovider"
"github.com/openshift/hypershift/control-plane-operator/controllers/hostedcontrolplane/manifests"
"github.com/openshift/hypershift/support/config"
"github.com/openshift/hypershift/support/util"
)
type KubeSchedulerParams struct {
FeatureGate *configv1.FeatureGateSpec `json:"featureGate"`
Scheduler *configv1.SchedulerSpec `json:"scheduler"`
OwnerRef config.OwnerRef `json:"ownerRef"`
HyperkubeImage string `json:"hyperkubeImage"`
AvailabilityProberImage string `json:"availabilityProberImage"`
config.DeploymentConfig `json:",inline"`
APIServer *configv1.APIServerSpec `json:"apiServer"`
DisableProfiling bool `json:"disableProfiling"`
}
func NewKubeSchedulerParams(ctx context.Context, hcp *hyperv1.HostedControlPlane, releaseImageProvider *imageprovider.ReleaseImageProvider, setDefaultSecurityContext bool) *KubeSchedulerParams {
params := &KubeSchedulerParams{
HyperkubeImage: releaseImageProvider.GetImage("hyperkube"),
AvailabilityProberImage: releaseImageProvider.GetImage(util.AvailabilityProberImageName),
}
if hcp.Spec.Configuration != nil {
params.FeatureGate = hcp.Spec.Configuration.FeatureGate
params.Scheduler = hcp.Spec.Configuration.Scheduler
params.APIServer = hcp.Spec.Configuration.APIServer
}
params.Scheduling = config.Scheduling{
PriorityClass: config.DefaultPriorityClass,
}
if hcp.Annotations[hyperv1.ControlPlanePriorityClass] != "" {
params.Scheduling.PriorityClass = hcp.Annotations[hyperv1.ControlPlanePriorityClass]
}
params.Resources = map[string]corev1.ResourceRequirements{
schedulerContainerMain().Name: {
Requests: corev1.ResourceList{
corev1.ResourceMemory: resource.MustParse("150Mi"),
corev1.ResourceCPU: resource.MustParse("25m"),
},
},
}
params.LivenessProbes = config.LivenessProbes{
schedulerContainerMain().Name: {
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/healthz",
Port: intstr.FromInt(schedulerSecurePort),
Scheme: corev1.URISchemeHTTPS,
},
},
InitialDelaySeconds: 60,
PeriodSeconds: 60,
SuccessThreshold: 1,
FailureThreshold: 5,
TimeoutSeconds: 5,
},
}
params.ReadinessProbes = config.ReadinessProbes{
schedulerContainerMain().Name: {
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/healthz",
Port: intstr.FromInt(schedulerSecurePort),
Scheme: corev1.URISchemeHTTPS,
},
},
InitialDelaySeconds: 15,
PeriodSeconds: 60,
SuccessThreshold: 1,
FailureThreshold: 3,
TimeoutSeconds: 5,
},
}
params.DeploymentConfig.SetDefaults(hcp, labels, nil)
params.DeploymentConfig.SetRestartAnnotation(hcp.ObjectMeta)
params.SetDefaultSecurityContext = setDefaultSecurityContext
params.DisableProfiling = util.StringListContains(hcp.Annotations[hyperv1.DisableProfilingAnnotation], manifests.SchedulerDeployment("").Name)
params.OwnerRef = config.OwnerRefFrom(hcp)
return params
}
func (p *KubeSchedulerParams) FeatureGates() []string {
if p.FeatureGate != nil {
return config.FeatureGates(&p.FeatureGate.FeatureGateSelection)
} else {
return config.FeatureGates(&configv1.FeatureGateSelection{FeatureSet: configv1.Default})
}
}
func (p *KubeSchedulerParams) CipherSuites() []string {
if p.APIServer != nil {
return config.CipherSuites(p.APIServer.TLSSecurityProfile)
}
return config.CipherSuites(nil)
}
func (p *KubeSchedulerParams) MinTLSVersion() string {
if p.APIServer != nil {
return config.MinTLSVersion(p.APIServer.TLSSecurityProfile)
}
return config.MinTLSVersion(nil)
}
func (p *KubeSchedulerParams) SchedulerPolicy() configv1.ConfigMapNameReference {
if p.Scheduler != nil {
return p.Scheduler.Policy
} else {
return configv1.ConfigMapNameReference{}
}
}
func (p *KubeSchedulerParams) SchedulerProfile() configv1.SchedulerProfile {
if p.Scheduler != nil && p.Scheduler.Profile != "" {
return p.Scheduler.Profile
} else {
return configv1.LowNodeUtilization
}
}