-
Notifications
You must be signed in to change notification settings - Fork 310
/
params.go
104 lines (94 loc) · 3.56 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
package ocm
import (
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/hypershift/v1beta1"
"github.com/openshift/hypershift/control-plane-operator/controllers/hostedcontrolplane/imageprovider"
"github.com/openshift/hypershift/support/config"
"github.com/openshift/hypershift/support/globalconfig"
)
type OpenShiftControllerManagerParams struct {
OpenShiftControllerManagerImage string
DockerBuilderImage string
DeployerImage string
APIServer *configv1.APIServerSpec
Network *configv1.NetworkSpec
Build *configv1.Build
Image *configv1.Image
DeploymentConfig config.DeploymentConfig
config.OwnerRef
}
func NewOpenShiftControllerManagerParams(hcp *hyperv1.HostedControlPlane, observedConfig *globalconfig.ObservedConfig, releaseImageProvider *imageprovider.ReleaseImageProvider, setDefaultSecurityContext bool) *OpenShiftControllerManagerParams {
params := &OpenShiftControllerManagerParams{
OpenShiftControllerManagerImage: releaseImageProvider.GetImage("openshift-controller-manager"),
DockerBuilderImage: releaseImageProvider.GetImage("docker-builder"),
DeployerImage: releaseImageProvider.GetImage("deployer"),
Build: observedConfig.Build,
Image: observedConfig.Image,
}
if hcp.Spec.Configuration != nil {
params.APIServer = hcp.Spec.Configuration.APIServer
params.Network = hcp.Spec.Configuration.Network
}
params.DeploymentConfig = config.DeploymentConfig{
Scheduling: config.Scheduling{
PriorityClass: config.DefaultPriorityClass,
},
Resources: map[string]corev1.ResourceRequirements{
ocmContainerMain().Name: {
Requests: corev1.ResourceList{
corev1.ResourceMemory: resource.MustParse("100Mi"),
corev1.ResourceCPU: resource.MustParse("100m"),
},
},
},
}
if hcp.Annotations[hyperv1.ControlPlanePriorityClass] != "" {
params.DeploymentConfig.Scheduling.PriorityClass = hcp.Annotations[hyperv1.ControlPlanePriorityClass]
}
params.DeploymentConfig.SetRestartAnnotation(hcp.ObjectMeta)
params.DeploymentConfig.SetDefaults(hcp, openShiftControllerManagerLabels(), nil)
params.DeploymentConfig.SetDefaultSecurityContext = setDefaultSecurityContext
params.DeploymentConfig.LivenessProbes = config.LivenessProbes{
ocmContainerMain().Name: {
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/healthz",
Port: intstr.FromInt(int(servingPort)),
Scheme: corev1.URISchemeHTTPS,
},
},
InitialDelaySeconds: 30,
TimeoutSeconds: 5,
},
}
params.DeploymentConfig.ReadinessProbes = config.ReadinessProbes{
ocmContainerMain().Name: {
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/healthz",
Port: intstr.FromInt(int(servingPort)),
Scheme: corev1.URISchemeHTTPS,
},
},
FailureThreshold: 10,
TimeoutSeconds: 5,
},
}
params.OwnerRef = config.OwnerRefFrom(hcp)
return params
}
func (p *OpenShiftControllerManagerParams) MinTLSVersion() string {
if p.APIServer != nil {
return config.MinTLSVersion(p.APIServer.TLSSecurityProfile)
}
return config.MinTLSVersion(nil)
}
func (p *OpenShiftControllerManagerParams) CipherSuites() []string {
if p.APIServer != nil {
return config.CipherSuites(p.APIServer.TLSSecurityProfile)
}
return config.CipherSuites(nil)
}