From 43108bfef274c379d92d578e1ee39a49caf3d72b Mon Sep 17 00:00:00 2001 From: Alfred Landrum Date: Wed, 18 May 2022 08:13:36 -0700 Subject: [PATCH] Issue 607: add toleration support for controller and segmentStore pods (#608) * add toleration support for controller and segmentStore pods Signed-off-by: Alfred Landrum * run make manifests Signed-off-by: Alfred Landrum * run controller-gen object ... updates by running: controller-gen object paths="./..." Signed-off-by: Alfred Landrum --- api/v1alpha1/zz_generated.deepcopy.go | 23 +----- api/v1beta1/pravega.go | 6 ++ api/v1beta1/zz_generated.deepcopy.go | 42 ++++------ api/v1beta1/zz_generated_deepcopy_test.go | 20 +++++ .../pravega.pravega.io_pravegaclusters.yaml | 82 +++++++++++++++++++ config/webhook/manifests.yaml | 28 +++++++ controllers/pravega_controller.go | 5 +- controllers/pravega_controller_test.go | 15 ++++ controllers/pravega_segmentstore.go | 5 +- controllers/pravega_segmentstore_test.go | 15 ++++ 10 files changed, 190 insertions(+), 51 deletions(-) create mode 100644 config/webhook/manifests.yaml diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 466a1839c..499e7e7da 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -6,14 +6,13 @@ package v1alpha1 import ( - v1 "k8s.io/api/core/v1" + "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AuthenticationParameters) DeepCopyInto(out *AuthenticationParameters) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthenticationParameters. @@ -30,7 +29,6 @@ func (in *AuthenticationParameters) DeepCopy() *AuthenticationParameters { func (in *BookkeeperImageSpec) DeepCopyInto(out *BookkeeperImageSpec) { *out = *in out.ImageSpec = in.ImageSpec - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BookkeeperImageSpec. @@ -66,7 +64,6 @@ func (in *BookkeeperJVMOptions) DeepCopyInto(out *BookkeeperJVMOptions) { *out = make([]string, len(*in)) copy(*out, *in) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BookkeeperJVMOptions. @@ -114,7 +111,6 @@ func (in *BookkeeperSpec) DeepCopyInto(out *BookkeeperSpec) { *out = new(BookkeeperJVMOptions) (*in).DeepCopyInto(*out) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BookkeeperSpec. @@ -145,7 +141,6 @@ func (in *BookkeeperStorageSpec) DeepCopyInto(out *BookkeeperStorageSpec) { *out = new(v1.PersistentVolumeClaimSpec) (*in).DeepCopyInto(*out) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BookkeeperStorageSpec. @@ -161,7 +156,6 @@ func (in *BookkeeperStorageSpec) DeepCopy() *BookkeeperStorageSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterCondition) DeepCopyInto(out *ClusterCondition) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterCondition. @@ -202,7 +196,6 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { *out = new(PravegaSpec) (*in).DeepCopyInto(*out) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSpec. @@ -229,7 +222,6 @@ func (in *ClusterStatus) DeepCopyInto(out *ClusterStatus) { copy(*out, *in) } in.Members.DeepCopyInto(&out.Members) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterStatus. @@ -245,7 +237,6 @@ func (in *ClusterStatus) DeepCopy() *ClusterStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ECSSpec) DeepCopyInto(out *ECSSpec) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ECSSpec. @@ -261,7 +252,6 @@ func (in *ECSSpec) DeepCopy() *ECSSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ExternalAccess) DeepCopyInto(out *ExternalAccess) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalAccess. @@ -282,7 +272,6 @@ func (in *FileSystemSpec) DeepCopyInto(out *FileSystemSpec) { *out = new(v1.PersistentVolumeClaimVolumeSource) **out = **in } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FileSystemSpec. @@ -298,7 +287,6 @@ func (in *FileSystemSpec) DeepCopy() *FileSystemSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HDFSSpec) DeepCopyInto(out *HDFSSpec) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HDFSSpec. @@ -314,7 +302,6 @@ func (in *HDFSSpec) DeepCopy() *HDFSSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ImageSpec) DeepCopyInto(out *ImageSpec) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageSpec. @@ -340,7 +327,6 @@ func (in *MembersStatus) DeepCopyInto(out *MembersStatus) { *out = make([]string, len(*in)) copy(*out, *in) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MembersStatus. @@ -360,7 +346,6 @@ func (in *PravegaCluster) DeepCopyInto(out *PravegaCluster) { in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PravegaCluster. @@ -393,7 +378,6 @@ func (in *PravegaClusterList) DeepCopyInto(out *PravegaClusterList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PravegaClusterList. @@ -418,7 +402,6 @@ func (in *PravegaClusterList) DeepCopyObject() runtime.Object { func (in *PravegaImageSpec) DeepCopyInto(out *PravegaImageSpec) { *out = *in out.ImageSpec = in.ImageSpec - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PravegaImageSpec. @@ -490,7 +473,6 @@ func (in *PravegaSpec) DeepCopyInto(out *PravegaSpec) { (*out)[key] = val } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PravegaSpec. @@ -506,7 +488,6 @@ func (in *PravegaSpec) DeepCopy() *PravegaSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StaticTLS) DeepCopyInto(out *StaticTLS) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StaticTLS. @@ -527,7 +508,6 @@ func (in *TLSPolicy) DeepCopyInto(out *TLSPolicy) { *out = new(StaticTLS) **out = **in } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TLSPolicy. @@ -558,7 +538,6 @@ func (in *Tier2Spec) DeepCopyInto(out *Tier2Spec) { *out = new(HDFSSpec) **out = **in } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Tier2Spec. diff --git a/api/v1beta1/pravega.go b/api/v1beta1/pravega.go index b07f0136b..e62cb58bb 100644 --- a/api/v1beta1/pravega.go +++ b/api/v1beta1/pravega.go @@ -324,6 +324,12 @@ type PravegaSpec struct { // SegmentStoreProbes specifies the values for configurable fields of Readiness and Liveness Probes // for the segmentstore pods. SegmentStoreProbes *Probes `json:"segmentStoreProbes,omitempty"` + + // Tolerations for the Controller pods. + ControllerPodTolerations []corev1.Toleration `json:"controllerPodTolerations,omitempty"` + + // Tolerations for the SegmentStore pods. + SegmentStorePodTolerations []corev1.Toleration `json:"segmentStorePodTolerations,omitempty"` } type Probes struct { diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index a1a2365ca..450c470ed 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -2,17 +2,17 @@ // +build !ignore_autogenerated // Code generated by controller-gen. DO NOT EDIT. + package v1beta1 import ( - v1 "k8s.io/api/core/v1" - runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AuthHandlerSpec) DeepCopyInto(out *AuthHandlerSpec) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthHandlerSpec. @@ -33,7 +33,6 @@ func (in *AuthImplementationSpec) DeepCopyInto(out *AuthImplementationSpec) { *out = make([]AuthHandlerSpec, len(*in)) copy(*out, *in) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthImplementationSpec. @@ -49,7 +48,6 @@ func (in *AuthImplementationSpec) DeepCopy() *AuthImplementationSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AuthenticationParameters) DeepCopyInto(out *AuthenticationParameters) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthenticationParameters. @@ -65,7 +63,6 @@ func (in *AuthenticationParameters) DeepCopy() *AuthenticationParameters { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterCondition) DeepCopyInto(out *ClusterCondition) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterCondition. @@ -101,7 +98,6 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { *out = new(PravegaSpec) (*in).DeepCopyInto(*out) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSpec. @@ -128,7 +124,6 @@ func (in *ClusterStatus) DeepCopyInto(out *ClusterStatus) { copy(*out, *in) } in.Members.DeepCopyInto(&out.Members) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterStatus. @@ -158,7 +153,6 @@ func (in *CustomSpec) DeepCopyInto(out *CustomSpec) { (*out)[key] = val } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomSpec. @@ -174,7 +168,6 @@ func (in *CustomSpec) DeepCopy() *CustomSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ECSSpec) DeepCopyInto(out *ECSSpec) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ECSSpec. @@ -190,7 +183,6 @@ func (in *ECSSpec) DeepCopy() *ECSSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ExternalAccess) DeepCopyInto(out *ExternalAccess) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalAccess. @@ -211,7 +203,6 @@ func (in *FileSystemSpec) DeepCopyInto(out *FileSystemSpec) { *out = new(v1.PersistentVolumeClaimVolumeSource) **out = **in } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FileSystemSpec. @@ -227,7 +218,6 @@ func (in *FileSystemSpec) DeepCopy() *FileSystemSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HDFSSpec) DeepCopyInto(out *HDFSSpec) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HDFSSpec. @@ -243,7 +233,6 @@ func (in *HDFSSpec) DeepCopy() *HDFSSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ImageSpec) DeepCopyInto(out *ImageSpec) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageSpec. @@ -259,7 +248,6 @@ func (in *ImageSpec) DeepCopy() *ImageSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InfluxDBSecret) DeepCopyInto(out *InfluxDBSecret) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InfluxDBSecret. @@ -295,7 +283,6 @@ func (in *LongTermStorageSpec) DeepCopyInto(out *LongTermStorageSpec) { *out = new(CustomSpec) (*in).DeepCopyInto(*out) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LongTermStorageSpec. @@ -321,7 +308,6 @@ func (in *MembersStatus) DeepCopyInto(out *MembersStatus) { *out = make([]string, len(*in)) copy(*out, *in) } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MembersStatus. @@ -341,7 +327,6 @@ func (in *PravegaCluster) DeepCopyInto(out *PravegaCluster) { in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PravegaCluster. @@ -374,7 +359,6 @@ func (in *PravegaClusterList) DeepCopyInto(out *PravegaClusterList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PravegaClusterList. @@ -541,7 +525,20 @@ func (in *PravegaSpec) DeepCopyInto(out *PravegaSpec) { *out = new(Probes) (*in).DeepCopyInto(*out) } - return + if in.ControllerPodTolerations != nil { + in, out := &in.ControllerPodTolerations, &out.ControllerPodTolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SegmentStorePodTolerations != nil { + in, out := &in.SegmentStorePodTolerations, &out.SegmentStorePodTolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PravegaSpec. @@ -557,7 +554,6 @@ func (in *PravegaSpec) DeepCopy() *PravegaSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Probe) DeepCopyInto(out *Probe) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Probe. @@ -583,7 +579,6 @@ func (in *Probes) DeepCopyInto(out *Probes) { *out = new(Probe) **out = **in } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Probes. @@ -599,7 +594,6 @@ func (in *Probes) DeepCopy() *Probes { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SegmentStoreSecret) DeepCopyInto(out *SegmentStoreSecret) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SegmentStoreSecret. @@ -615,7 +609,6 @@ func (in *SegmentStoreSecret) DeepCopy() *SegmentStoreSecret { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StaticTLS) DeepCopyInto(out *StaticTLS) { *out = *in - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StaticTLS. @@ -636,7 +629,6 @@ func (in *TLSPolicy) DeepCopyInto(out *TLSPolicy) { *out = new(StaticTLS) **out = **in } - return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TLSPolicy. diff --git a/api/v1beta1/zz_generated_deepcopy_test.go b/api/v1beta1/zz_generated_deepcopy_test.go index 69a1e277a..cf6340777 100644 --- a/api/v1beta1/zz_generated_deepcopy_test.go +++ b/api/v1beta1/zz_generated_deepcopy_test.go @@ -75,6 +75,22 @@ var _ = Describe("PravegaCluster DeepCopy", func() { }, }, }, + ControllerPodTolerations: []corev1.Toleration{ + { + Key: "controller", + Operator: "Equal", + Value: "val1", + Effect: "NoSchedule", + }, + }, + SegmentStorePodTolerations: []corev1.Toleration{ + { + Key: "segmentStore", + Operator: "Equal", + Value: "val1", + Effect: "NoSchedule", + }, + }, }, } p1.WithDefaults() @@ -397,5 +413,9 @@ var _ = Describe("PravegaCluster DeepCopy", func() { Ω(p2.Spec.Pravega.ControllerProbes.ReadinessProbe.InitialDelaySeconds).To(Equal(int32(0))) Ω(p2.Spec.Pravega.SegmentStoreProbes.LivenessProbe.FailureThreshold).To(Equal(int32(1))) }) + It("checking pod tolerations", func() { + Ω(p2.Spec.Pravega.ControllerPodTolerations[0].Key).To(Equal("controller")) + Ω(p2.Spec.Pravega.SegmentStorePodTolerations[0].Key).To(Equal("segmentStore")) + }) }) }) diff --git a/config/crd/bases/pravega.pravega.io_pravegaclusters.yaml b/config/crd/bases/pravega.pravega.io_pravegaclusters.yaml index 1160d6e70..b6841cb50 100644 --- a/config/crd/bases/pravega.pravega.io_pravegaclusters.yaml +++ b/config/crd/bases/pravega.pravega.io_pravegaclusters.yaml @@ -3578,6 +3578,47 @@ spec: type: string description: Labels to be added to the Controller pods type: object + controllerPodTolerations: + description: Tolerations for the Controller pods. + items: + description: The pod this Toleration is attached to tolerates + any taint that matches the triple using + the matching operator . + properties: + effect: + description: Effect indicates the taint effect to match. + Empty means match all taint effects. When specified, allowed + values are NoSchedule, PreferNoSchedule and NoExecute. + type: string + key: + description: Key is the taint key that the toleration applies + to. Empty means match all taint keys. If the key is empty, + operator must be Exists; this combination means to match + all values and all keys. + type: string + operator: + description: Operator represents a key's relationship to + the value. Valid operators are Exists and Equal. Defaults + to Equal. Exists is equivalent to wildcard for value, + so that a pod can tolerate all taints of a particular + category. + type: string + tolerationSeconds: + description: TolerationSeconds represents the period of + time the toleration (which must be of effect NoExecute, + otherwise this field is ignored) tolerates the taint. + By default, it is not set, which means tolerate the taint + forever (do not evict). Zero and negative values will + be treated as 0 (evict immediately) by the system. + format: int64 + type: integer + value: + description: Value is the taint value the toleration matches + to. If the operator is Exists, the value should be empty, + otherwise just a regular string. + type: string + type: object + type: array controllerProbes: description: ControllerProbes specifies the values for configurable fields of Readiness and Liveness Probes for the controller pods. @@ -6131,6 +6172,47 @@ spec: type: string description: Labels to be added to the SegmentStore pods type: object + segmentStorePodTolerations: + description: Tolerations for the SegmentStore pods. + items: + description: The pod this Toleration is attached to tolerates + any taint that matches the triple using + the matching operator . + properties: + effect: + description: Effect indicates the taint effect to match. + Empty means match all taint effects. When specified, allowed + values are NoSchedule, PreferNoSchedule and NoExecute. + type: string + key: + description: Key is the taint key that the toleration applies + to. Empty means match all taint keys. If the key is empty, + operator must be Exists; this combination means to match + all values and all keys. + type: string + operator: + description: Operator represents a key's relationship to + the value. Valid operators are Exists and Equal. Defaults + to Equal. Exists is equivalent to wildcard for value, + so that a pod can tolerate all taints of a particular + category. + type: string + tolerationSeconds: + description: TolerationSeconds represents the period of + time the toleration (which must be of effect NoExecute, + otherwise this field is ignored) tolerates the taint. + By default, it is not set, which means tolerate the taint + forever (do not evict). Zero and negative values will + be treated as 0 (evict immediately) by the system. + format: int64 + type: integer + value: + description: Value is the taint value the toleration matches + to. If the operator is Exists, the value should be empty, + otherwise just a regular string. + type: string + type: object + type: array segmentStoreProbes: description: SegmentStoreProbes specifies the values for configurable fields of Readiness and Liveness Probes for the segmentstore diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml new file mode 100644 index 000000000..8f916bd2c --- /dev/null +++ b/config/webhook/manifests.yaml @@ -0,0 +1,28 @@ + +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingWebhookConfiguration +metadata: + creationTimestamp: null + name: validating-webhook-configuration +webhooks: +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-pravegaclusters-pravega-pravega-io-v1beta1-pravegacluster + failurePolicy: Fail + name: vpravegacluster.kb.io + rules: + - apiGroups: + - pravegaclusters.pravega.pravega.io + apiVersions: + - v1beta1 + operations: + - CREATE + - UPDATE + resources: + - pravegaclusters + sideEffects: None diff --git a/controllers/pravega_controller.go b/controllers/pravega_controller.go index 42fef33dc..ea21c901d 100644 --- a/controllers/pravega_controller.go +++ b/controllers/pravega_controller.go @@ -196,8 +196,9 @@ func makeControllerPodSpec(p *api.PravegaCluster) *corev1.PodSpec { }, }, }, - Affinity: p.Spec.Pravega.ControllerPodAffinity, - Volumes: volumes, + Affinity: p.Spec.Pravega.ControllerPodAffinity, + Volumes: volumes, + Tolerations: p.Spec.Pravega.ControllerPodTolerations, } if p.Spec.Pravega.ControllerServiceAccountName != "" { podSpec.ServiceAccountName = p.Spec.Pravega.ControllerServiceAccountName diff --git a/controllers/pravega_controller_test.go b/controllers/pravega_controller_test.go index ecb0b3c0f..fa9f88125 100644 --- a/controllers/pravega_controller_test.go +++ b/controllers/pravega_controller_test.go @@ -128,6 +128,14 @@ var _ = Describe("Controller", func() { TimeoutSeconds: 2, }, }, + ControllerPodTolerations: []corev1.Toleration{ + { + Key: "controller", + Operator: "Equal", + Value: "val1", + Effect: "NoSchedule", + }, + }, }, TLS: &v1beta1.TLSPolicy{ Static: &v1beta1.StaticTLS{ @@ -231,6 +239,13 @@ var _ = Describe("Controller", func() { Ω(podTemplate.Spec.Containers[0].ReadinessProbe.SuccessThreshold).Should(Equal(int32(1))) Ω(podTemplate.Spec.Containers[0].ReadinessProbe.TimeoutSeconds).Should(Equal(int32(2))) }) + It("should have controller pod tolerations", func() { + podTemplate := pravega.MakeControllerPodTemplate(p) + Ω(podTemplate.Spec.Tolerations[0].Key).Should(Equal("controller")) + Ω(podTemplate.Spec.Tolerations[0].Operator).Should(Equal(corev1.TolerationOperator("Equal"))) + Ω(podTemplate.Spec.Tolerations[0].Value).Should(Equal("val1")) + Ω(podTemplate.Spec.Tolerations[0].Effect).Should(Equal(corev1.TaintEffect("NoSchedule"))) + }) }) Context("Controller with external service type and external access type empty", func() { diff --git a/controllers/pravega_segmentstore.go b/controllers/pravega_segmentstore.go index 77b697842..c2fdfa73f 100644 --- a/controllers/pravega_segmentstore.go +++ b/controllers/pravega_segmentstore.go @@ -238,8 +238,9 @@ func makeSegmentstorePodSpec(p *api.PravegaCluster) corev1.PodSpec { }, }, }, - Affinity: p.Spec.Pravega.SegmentStorePodAffinity, - Volumes: volumes, + Affinity: p.Spec.Pravega.SegmentStorePodAffinity, + Volumes: volumes, + Tolerations: p.Spec.Pravega.SegmentStorePodTolerations, } if p.Spec.Pravega.SegmentStoreServiceAccountName != "" { diff --git a/controllers/pravega_segmentstore_test.go b/controllers/pravega_segmentstore_test.go index 360d157ad..ae75cc243 100644 --- a/controllers/pravega_segmentstore_test.go +++ b/controllers/pravega_segmentstore_test.go @@ -124,6 +124,14 @@ var _ = Describe("PravegaSegmentstore", func() { TimeoutSeconds: 2, }, }, + SegmentStorePodTolerations: []corev1.Toleration{ + { + Key: "segmentStore", + Operator: "Equal", + Value: "val1", + Effect: "NoSchedule", + }, + }, }, TLS: &v1beta1.TLSPolicy{ Static: &v1beta1.StaticTLS{ @@ -236,6 +244,13 @@ var _ = Describe("PravegaSegmentstore", func() { Ω(podTemplate.Spec.Containers[0].ReadinessProbe.SuccessThreshold).Should(Equal(int32(1))) Ω(podTemplate.Spec.Containers[0].ReadinessProbe.TimeoutSeconds).Should(Equal(int32(2))) }) + It("should have segmentStore pod tolerations", func() { + podTemplate := pravega.MakeSegmentStorePodTemplate(p) + Ω(podTemplate.Spec.Tolerations[0].Key).Should(Equal("segmentStore")) + Ω(podTemplate.Spec.Tolerations[0].Operator).Should(Equal(corev1.TolerationOperator("Equal"))) + Ω(podTemplate.Spec.Tolerations[0].Value).Should(Equal("val1")) + Ω(podTemplate.Spec.Tolerations[0].Effect).Should(Equal(corev1.TaintEffect("NoSchedule"))) + }) }) })