@@ -22,36 +22,42 @@ import (
22
22
"github.com/awslabs/kit/operator/pkg/apis/controlplane/v1alpha1"
23
23
"github.com/awslabs/kit/operator/pkg/utils/imageprovider"
24
24
"github.com/awslabs/kit/operator/pkg/utils/object"
25
+ "github.com/awslabs/kit/operator/pkg/utils/patch"
25
26
appsv1 "k8s.io/api/apps/v1"
26
27
v1 "k8s.io/api/core/v1"
27
28
"k8s.io/apimachinery/pkg/api/resource"
28
29
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29
30
)
30
31
31
- func (c * Controller ) reconcileScheduler (ctx context.Context , controlPlane * v1alpha1.ControlPlane ) error {
32
- return c . kubeClient . EnsurePatch ( ctx , & appsv1. Deployment {}, object . WithOwner (controlPlane , schedulerDeploymentSpec ( controlPlane )) )
33
- }
34
-
35
- func schedulerDeploymentSpec ( controlPlane * v1alpha1. ControlPlane ) * appsv1. Deployment {
36
- return & appsv1. Deployment {
37
- ObjectMeta : metav1. ObjectMeta {
38
- Name : SchedulerDeploymentName ( controlPlane . ClusterName ()),
39
- Namespace : controlPlane . Namespace ,
40
- },
41
- Spec : appsv1. DeploymentSpec {
42
- Selector : & metav1. LabelSelector {
43
- MatchLabels : schedulerLabels ( controlPlane .ClusterName ()) ,
32
+ func (c * Controller ) reconcileScheduler (ctx context.Context , controlPlane * v1alpha1.ControlPlane ) ( err error ) {
33
+ schedulerPodSpec := schedulerPodSpecFor (controlPlane )
34
+ if controlPlane . Spec . Master . Scheduler != nil {
35
+ schedulerPodSpec , err = patch . PodSpec ( & schedulerPodSpec , controlPlane . Spec . Master . Scheduler . Spec )
36
+ if err != nil {
37
+ return fmt . Errorf ( "patch scheduler pod spec, %w" , err )
38
+ }
39
+ }
40
+ return c . kubeClient . EnsurePatch ( ctx , & appsv1. Deployment {} ,
41
+ object . WithOwner ( controlPlane , & appsv1. Deployment {
42
+ ObjectMeta : metav1. ObjectMeta {
43
+ Name : SchedulerDeploymentName ( controlPlane . ClusterName ()),
44
+ Namespace : controlPlane .Namespace ,
44
45
},
45
- Replicas : aws .Int32 (3 ),
46
- Strategy : appsv1.DeploymentStrategy {Type : appsv1 .RecreateDeploymentStrategyType },
47
- Template : v1.PodTemplateSpec {
48
- ObjectMeta : metav1.ObjectMeta {
49
- Labels : schedulerLabels (controlPlane .ClusterName ()),
46
+ Spec : appsv1.DeploymentSpec {
47
+ Selector : & metav1.LabelSelector {
48
+ MatchLabels : schedulerLabels (controlPlane .ClusterName ()),
49
+ },
50
+ Replicas : aws .Int32 (3 ),
51
+ Strategy : appsv1.DeploymentStrategy {Type : appsv1 .RecreateDeploymentStrategyType },
52
+ Template : v1.PodTemplateSpec {
53
+ ObjectMeta : metav1.ObjectMeta {
54
+ Labels : schedulerLabels (controlPlane .ClusterName ()),
55
+ },
56
+ Spec : schedulerPodSpec ,
50
57
},
51
- Spec : * schedulerPodSpecFor (controlPlane ),
52
58
},
53
- },
54
- }
59
+ }) ,
60
+ )
55
61
}
56
62
57
63
func SchedulerDeploymentName (clusterName string ) string {
@@ -64,9 +70,9 @@ func schedulerLabels(clustername string) map[string]string {
64
70
}
65
71
}
66
72
67
- func schedulerPodSpecFor (controlPlane * v1alpha1.ControlPlane ) * v1.PodSpec {
73
+ func schedulerPodSpecFor (controlPlane * v1alpha1.ControlPlane ) v1.PodSpec {
68
74
hostPathDirectoryOrCreate := v1 .HostPathDirectoryOrCreate
69
- return & v1.PodSpec {
75
+ return v1.PodSpec {
70
76
TerminationGracePeriodSeconds : aws .Int64 (1 ),
71
77
HostNetwork : true ,
72
78
DNSPolicy : v1 .DNSClusterFirstWithHostNet ,
0 commit comments