diff --git a/api/v1beta1/kafkacluster_types.go b/api/v1beta1/kafkacluster_types.go index 26342c73d..1839c8a63 100644 --- a/api/v1beta1/kafkacluster_types.go +++ b/api/v1beta1/kafkacluster_types.go @@ -218,6 +218,11 @@ type BrokerConfig struct { // +kubebuilder:default=120 // +optional TerminationGracePeriod *int64 `json:"terminationGracePeriodSeconds,omitempty"` + // PriorityClassName specifies the priority class name for a broker pod(s). + // If specified, the PriorityClass resource with this PriorityClassName must be created beforehand. + // If not specified, the broker pods' priority is default to zero. + // +optional + PriorityClassName string `json:"priorityClassName,omitempty"` } type NetworkConfig struct { @@ -257,6 +262,11 @@ type CruiseControlConfig struct { PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` // SecurityContext allows to set security context for the CruiseControl container SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"` + // PriorityClassName specifies the priority class name for the CruiseControl pod. + // If specified, the PriorityClass resource with this PriorityClassName must be created beforehand. + // If not specified, the CruiseControl pod's priority is default to zero. + // +optional + PriorityClassName string `json:"priorityClassName,omitempty"` } // CruiseControlTaskSpec specifies the configuration of the CC Tasks @@ -292,7 +302,7 @@ type EnvoyConfig struct { // If specified and supported by the platform, traffic through the // cloud-provider load-balancer will be restricted to the specified client // IPs. This field will be ignored if the - // cloud-provider does not support the feature." + // cloud-provider does not support the feature. // More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/ LoadBalancerSourceRanges []string `json:"loadBalancerSourceRanges,omitempty"` // LoadBalancerIP can be used to specify an exact IP for the LoadBalancer service @@ -307,6 +317,11 @@ type EnvoyConfig struct { // +optional // +kubebuilder:pruning:PreserveUnknownFields CommandLineArgs *EnvoyCommandLineArgs `json:"envoyCommandLineArgs,omitempty"` + // PriorityClassName specifies the priority class name for the Envoy pod(s) + // If specified, the PriorityClass resource with this PriorityClassName must be created beforehand + // If not specified, the Envoy pods' priority is default to zero + // +optional + PriorityClassName string `json:"priorityClassName,omitempty"` } // EnvoyCommandLineArgs defines envoy command line arguments @@ -790,11 +805,21 @@ func (eConfig *EnvoyConfig) GetTopologySpreadConstaints() []corev1.TopologySprea return eConfig.TopologySpreadConstraints } +// GetPriorityClassName returns the priority class name for envoy +func (eConfig *EnvoyConfig) GetPriorityClassName() string { + return eConfig.PriorityClassName +} + // GetNodeSelector returns the node selector for the given broker func (bConfig *BrokerConfig) GetNodeSelector() map[string]string { return bConfig.NodeSelector } +// GetPriorityClassName returns the priority class name for the given broker +func (bConfig *BrokerConfig) GetPriorityClassName() string { + return bConfig.PriorityClassName +} + // GetImagePullSecrets returns the list of Secrets needed to pull Containers images from private repositories func (bConfig *BrokerConfig) GetImagePullSecrets() []corev1.LocalObjectReference { return bConfig.ImagePullSecrets @@ -829,6 +854,11 @@ func (cConfig *CruiseControlConfig) GetImagePullSecrets() []corev1.LocalObjectRe return cConfig.ImagePullSecrets } +// GetPriorityClassName returns the priority class name for the CruiseControl pod +func (cConfig *CruiseControlConfig) GetPriorityClassName() string { + return cConfig.PriorityClassName +} + // GetResources returns the envoy specific Kubernetes resource func (eConfig *EnvoyConfig) GetResources() *corev1.ResourceRequirements { if eConfig.Resources != nil { diff --git a/charts/kafka-operator/templates/crds.yaml b/charts/kafka-operator/templates/crds.yaml index c03a153fe..7d93c76e0 100644 --- a/charts/kafka-operator/templates/crds.yaml +++ b/charts/kafka-operator/templates/crds.yaml @@ -3889,6 +3889,13 @@ spec: type: string type: object type: object + priorityClassName: + description: PriorityClassName specifies the priority class + name for a broker pod(s). If specified, the PriorityClass + resource with this PriorityClassName must be created beforehand. + If not specified, the broker pods' priority is default to + zero. + type: string resourceRequirements: description: ResourceRequirements describes the compute resource requirements. @@ -10014,6 +10021,13 @@ spec: type: string type: object type: object + priorityClassName: + description: PriorityClassName specifies the priority class + name for a broker pod(s). If specified, the PriorityClass + resource with this PriorityClassName must be created beforehand. + If not specified, the broker pods' priority is default + to zero. + type: string resourceRequirements: description: ResourceRequirements describes the compute resource requirements. @@ -13747,6 +13761,12 @@ spec: type: string type: object type: object + priorityClassName: + description: PriorityClassName specifies the priority class name + for the CruiseControl pod. If specified, the PriorityClass resource + with this PriorityClassName must be created beforehand. If not + specified, the CruiseControl pod's priority is default to zero. + type: string resourceRequirements: description: ResourceRequirements describes the compute resource requirements. @@ -16568,7 +16588,7 @@ spec: description: 'If specified and supported by the platform, traffic through the cloud-provider load-balancer will be restricted to the specified client IPs. This field will be ignored if the - cloud-provider does not support the feature." More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/' + cloud-provider does not support the feature. More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/' items: type: string type: array @@ -16578,6 +16598,12 @@ spec: description: NodeSelector is the node selector expression for envoy pods type: object + priorityClassName: + description: PriorityClassName specifies the priority class name + for the Envoy pod(s) If specified, the PriorityClass resource + with this PriorityClassName must be created beforehand If not + specified, the Envoy pods' priority is default to zero + type: string replicas: format: int32 minimum: 1 @@ -18575,7 +18601,7 @@ spec: load-balancer will be restricted to the specified client IPs. This field will be ignored if the cloud-provider does not support - the feature." More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/' + the feature. More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/' items: type: string type: array @@ -18585,6 +18611,14 @@ spec: description: NodeSelector is the node selector expression for envoy pods type: object + priorityClassName: + description: PriorityClassName specifies the + priority class name for the Envoy pod(s) + If specified, the PriorityClass resource + with this PriorityClassName must be created + beforehand If not specified, the Envoy pods' + priority is default to zero + type: string replicas: format: int32 minimum: 1 diff --git a/config/base/crds/kafka.banzaicloud.io_kafkaclusters.yaml b/config/base/crds/kafka.banzaicloud.io_kafkaclusters.yaml index a93d4ba02..55f1a5566 100644 --- a/config/base/crds/kafka.banzaicloud.io_kafkaclusters.yaml +++ b/config/base/crds/kafka.banzaicloud.io_kafkaclusters.yaml @@ -3888,6 +3888,13 @@ spec: type: string type: object type: object + priorityClassName: + description: PriorityClassName specifies the priority class + name for a broker pod(s). If specified, the PriorityClass + resource with this PriorityClassName must be created beforehand. + If not specified, the broker pods' priority is default to + zero. + type: string resourceRequirements: description: ResourceRequirements describes the compute resource requirements. @@ -10013,6 +10020,13 @@ spec: type: string type: object type: object + priorityClassName: + description: PriorityClassName specifies the priority class + name for a broker pod(s). If specified, the PriorityClass + resource with this PriorityClassName must be created beforehand. + If not specified, the broker pods' priority is default + to zero. + type: string resourceRequirements: description: ResourceRequirements describes the compute resource requirements. @@ -13746,6 +13760,12 @@ spec: type: string type: object type: object + priorityClassName: + description: PriorityClassName specifies the priority class name + for the CruiseControl pod. If specified, the PriorityClass resource + with this PriorityClassName must be created beforehand. If not + specified, the CruiseControl pod's priority is default to zero. + type: string resourceRequirements: description: ResourceRequirements describes the compute resource requirements. @@ -16567,7 +16587,7 @@ spec: description: 'If specified and supported by the platform, traffic through the cloud-provider load-balancer will be restricted to the specified client IPs. This field will be ignored if the - cloud-provider does not support the feature." More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/' + cloud-provider does not support the feature. More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/' items: type: string type: array @@ -16577,6 +16597,12 @@ spec: description: NodeSelector is the node selector expression for envoy pods type: object + priorityClassName: + description: PriorityClassName specifies the priority class name + for the Envoy pod(s) If specified, the PriorityClass resource + with this PriorityClassName must be created beforehand If not + specified, the Envoy pods' priority is default to zero + type: string replicas: format: int32 minimum: 1 @@ -18574,7 +18600,7 @@ spec: load-balancer will be restricted to the specified client IPs. This field will be ignored if the cloud-provider does not support - the feature." More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/' + the feature. More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/' items: type: string type: array @@ -18584,6 +18610,14 @@ spec: description: NodeSelector is the node selector expression for envoy pods type: object + priorityClassName: + description: PriorityClassName specifies the + priority class name for the Envoy pod(s) + If specified, the PriorityClass resource + with this PriorityClassName must be created + beforehand If not specified, the Envoy pods' + priority is default to zero + type: string replicas: format: int32 minimum: 1 diff --git a/config/samples/banzaicloud_v1beta1_kafkacluster.yaml b/config/samples/banzaicloud_v1beta1_kafkacluster.yaml index 131a1a4bd..2b113adc4 100644 --- a/config/samples/banzaicloud_v1beta1_kafkacluster.yaml +++ b/config/samples/banzaicloud_v1beta1_kafkacluster.yaml @@ -69,6 +69,9 @@ spec: # Add custom labels to broker pods within the config group # brokerLabels: # kafka_broker_group: "default_group" + # priorityClassName can be used to set the priority of broker pods that use this config group + # note that the corresponding PriorityClass must be created beforehand + # priorityClassName: "high-priority" # All Broker requires an image, unique id, and storageConfigs settings brokers: # Unique broker id which is used as kafka config broker.id @@ -102,6 +105,8 @@ spec: # tolerations: # config parameter can be used to pass Kafka config https://kafka.apache.org/documentation/#brokerconfigs # which has type per-broker + # priorityClassName can be used to set the broker pod's priority + # priorityClassName: "high-priority" config: | sasl.enabled.mechanisms=PLAIN # serviceAccountName specifies the serviceAccount used for this specific broker @@ -235,6 +240,8 @@ spec: # replicas: 1 # image describes the Envoy docker image # image: "banzaicloud/envoy:0.1.0" + # priorityClassName can be used to set the envoy pod's priority + # priorityClassName: "moderate-priority" # resourceRequirements works exactly like Container resources, the user can specify the limit and the requests # through this property # resourceRequirements: @@ -365,6 +372,8 @@ spec: cruiseControlConfig: # image describes the CC docker image #image: "solsson/kafka-cruise-control@sha256:c70eae329b4ececba58e8cf4fa6e774dd2e0205988d8e5be1a70e622fcc46716" + # priorityClassName can be used to set the cruise control pod's priority + # priorityClassName: "low-priority" # CruiseControlEndpoint describes the endpoint where the already running CC is accessable. If set the Operator will not # try to install one #cruiseControlEndpoint: "localhost:8090" diff --git a/pkg/resources/cruisecontrol/deployment.go b/pkg/resources/cruisecontrol/deployment.go index 5d34a49dc..9b2a5614d 100644 --- a/pkg/resources/cruisecontrol/deployment.go +++ b/pkg/resources/cruisecontrol/deployment.go @@ -176,6 +176,7 @@ fi`}, }, }, }...), + PriorityClassName: r.KafkaCluster.Spec.CruiseControlConfig.GetPriorityClassName(), }, }, }, diff --git a/pkg/resources/envoy/deployment.go b/pkg/resources/envoy/deployment.go index 4519fa75b..0bf50d757 100644 --- a/pkg/resources/envoy/deployment.go +++ b/pkg/resources/envoy/deployment.go @@ -117,7 +117,8 @@ func (r *Reconciler) deployment(log logr.Logger, extListener v1beta1.ExternalLis Resources: *ingressConfig.EnvoyConfig.GetResources(), }, }, - Volumes: volumes, + Volumes: volumes, + PriorityClassName: ingressConfig.EnvoyConfig.GetPriorityClassName(), }, }, }, diff --git a/pkg/resources/kafka/pod.go b/pkg/resources/kafka/pod.go index 92374411f..010d73fd8 100644 --- a/pkg/resources/kafka/pod.go +++ b/pkg/resources/kafka/pod.go @@ -157,6 +157,7 @@ fi`}, ServiceAccountName: brokerConfig.GetServiceAccount(), Tolerations: brokerConfig.GetTolerations(), NodeSelector: brokerConfig.GetNodeSelector(), + PriorityClassName: brokerConfig.GetPriorityClassName(), }, } if r.KafkaCluster.Spec.HeadlessServiceEnabled {