diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e1b2a864f..7386ceaa7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [PR #76](https://github.com/konpyutaika/nifikop/pull/76) - **[Operator/NiFiCluster]** Add ability to override default authorizers.xml template. - [PR #95](https://github.com/konpyutaika/nifikop/pull/95) - **[Operator/NiFiParameterContext]** Allow the operator to take over existing parameter context. +- [PR #96](https://github.com/konpyutaika/nifikop/pull/96) - **[Operator/NifiCluster]** Add ability to specify pod priority class ### Changed diff --git a/api/v1alpha1/nificluster_types.go b/api/v1alpha1/nificluster_types.go index c44d06936c..5910d4f6e1 100644 --- a/api/v1alpha1/nificluster_types.go +++ b/api/v1alpha1/nificluster_types.go @@ -298,6 +298,9 @@ type NodeConfig struct { Tolerations []corev1.Toleration `json:"tolerations,omitempty"` // podMetadata allows to add additionnal metadata to the node pods PodMetadata Metadata `json:"podMetadata,omitempty"` + // priorityClassName can be used to set the priority class applied to the node + // +optional + PriorityClassName *string `json:"priorityClassName,omitempty"` } type Metadata struct { @@ -655,6 +658,14 @@ func (nConfig *NodeConfig) GetResources() *corev1.ResourceRequirements { } } +// GetPriorityClass returns the name of the priority class to use for the given node +func (nConfig *NodeConfig) GetPriorityClass() string { + if nConfig.PriorityClassName != nil { + return *nConfig.PriorityClassName + } + return "" +} + // func (nConfig *NodeConfig) GetRunAsUser() *int64 { var defaultUserID int64 = 1000 diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index e64dbcb10c..41cbe881b9 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -1229,6 +1229,11 @@ func (in *NodeConfig) DeepCopyInto(out *NodeConfig) { } } in.PodMetadata.DeepCopyInto(&out.PodMetadata) + if in.PriorityClassName != nil { + in, out := &in.PriorityClassName, &out.PriorityClassName + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeConfig. diff --git a/config/crd/bases/nifi.konpyutaika.com_nificlusters.yaml b/config/crd/bases/nifi.konpyutaika.com_nificlusters.yaml index b69c5a7ce0..5cb4edf373 100644 --- a/config/crd/bases/nifi.konpyutaika.com_nificlusters.yaml +++ b/config/crd/bases/nifi.konpyutaika.com_nificlusters.yaml @@ -3427,6 +3427,10 @@ spec: associated https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set type: object type: object + priorityClassName: + description: priorityClassName can be used to set the priority + class applied to the node + type: string provenanceStorage: description: provenanceStorage allow to specify the maximum amount of data provenance information to store at a time https://nifi.apache.org/docs/nifi-docs/html/administration-guide.html#write-ahead-provenance-repository-properties @@ -5670,6 +5674,10 @@ spec: associated https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set type: object type: object + priorityClassName: + description: priorityClassName can be used to set the priority + class applied to the node + type: string provenanceStorage: description: provenanceStorage allow to specify the maximum amount of data provenance information to store at a time diff --git a/helm/nifikop/crds/nifi.konpyutaika.com_nificlusters.yaml b/helm/nifikop/crds/nifi.konpyutaika.com_nificlusters.yaml index b69c5a7ce0..5cb4edf373 100644 --- a/helm/nifikop/crds/nifi.konpyutaika.com_nificlusters.yaml +++ b/helm/nifikop/crds/nifi.konpyutaika.com_nificlusters.yaml @@ -3427,6 +3427,10 @@ spec: associated https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set type: object type: object + priorityClassName: + description: priorityClassName can be used to set the priority + class applied to the node + type: string provenanceStorage: description: provenanceStorage allow to specify the maximum amount of data provenance information to store at a time https://nifi.apache.org/docs/nifi-docs/html/administration-guide.html#write-ahead-provenance-repository-properties @@ -5670,6 +5674,10 @@ spec: associated https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set type: object type: object + priorityClassName: + description: priorityClassName can be used to set the priority + class applied to the node + type: string provenanceStorage: description: provenanceStorage allow to specify the maximum amount of data provenance information to store at a time diff --git a/pkg/resources/nifi/pod.go b/pkg/resources/nifi/pod.go index 2d9a8aa702..4419af2e55 100644 --- a/pkg/resources/nifi/pod.go +++ b/pkg/resources/nifi/pod.go @@ -169,7 +169,7 @@ done`, DNSPolicy: corev1.DNSClusterFirst, ImagePullSecrets: nodeConfig.GetImagePullSecrets(), ServiceAccountName: nodeConfig.GetServiceAccount(), - Priority: util.Int32Pointer(0), + PriorityClassName: nodeConfig.GetPriorityClass(), SchedulerName: "default-scheduler", Tolerations: nodeConfig.GetTolerations(), NodeSelector: nodeConfig.GetNodeSelector(), diff --git a/site/docs/5_references/1_nifi_cluster/3_node_config.md b/site/docs/5_references/1_nifi_cluster/3_node_config.md index 2cfdba7cd0..5d1733dd6f 100644 --- a/site/docs/5_references/1_nifi_cluster/3_node_config.md +++ b/site/docs/5_references/1_nifi_cluster/3_node_config.md @@ -31,6 +31,8 @@ NodeConfig defines the node configuration # nodeAffinity: # imagePullPolicy define the pull policy for NiFi cluster docker image imagePullPolicy: IfNotPresent + # priorityClassName define the name of the priority class to be applied to these nodes + priorityClassName: "example-priority-class-name" # externalVolumeConfigs specifies a list of volume to mount into the main container. externalVolumeConfigs: - name: example-volume @@ -82,6 +84,7 @@ NodeConfig defines the node configuration | nodeSelector | map\[string\]string |nodeSelector can be specified, which set the pod to fit on a node [nodeselector](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector)|No|nil| | tolerations | \[ \][Toleration](https://godoc.org/k8s.io/api/core/v1#Toleration) |tolerations can be specified, which set the pod's tolerations [taint-and-toleration](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/#concepts).|No|nil| | podMetadata | [Metadata](#metadata) |define additionnal metadata to merge to the pod associated.|No|nil| +| priorityClassName | string | Specify the name of the priority class to apply to pods created with this node config | No | nil| ## StorageConfig