From 329b3912a04fc4bcf0f29d4262a0ef03c58a385b Mon Sep 17 00:00:00 2001 From: Cannon Palms Date: Mon, 9 May 2022 15:00:03 -0400 Subject: [PATCH 1/3] feat(priority-classes): Support podPriorityClass def on node config --- api/v1alpha1/nificluster_types.go | 11 +++++++++++ api/v1alpha1/zz_generated.deepcopy.go | 5 +++++ .../crd/bases/nifi.konpyutaika.com_nificlusters.yaml | 8 ++++++++ .../crds/nifi.konpyutaika.com_nificlusters.yaml | 8 ++++++++ pkg/resources/nifi/pod.go | 2 +- 5 files changed, 33 insertions(+), 1 deletion(-) 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 6fa0bee286..ce7ea0f714 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -1224,6 +1224,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(), From 2f97bc18a5dcd58a5dd7aae80f9604c9e2b18676 Mon Sep 17 00:00:00 2001 From: Cannon Palms Date: Mon, 9 May 2022 15:12:05 -0400 Subject: [PATCH 2/3] docs(priority-classes): Add podPriorityClass docs to node config docs --- site/docs/5_references/1_nifi_cluster/3_node_config.md | 3 +++ 1 file changed, 3 insertions(+) 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 From 07f71eeb3681c14a98bba5518d2361d5c07a4a40 Mon Sep 17 00:00:00 2001 From: Cannon Palms Date: Tue, 17 May 2022 11:56:13 -0400 Subject: [PATCH 3/3] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2247846b8e..1fff284186 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Added - [PR #76](https://github.com/konpyutaika/nifikop/pull/76) - **[Operator/NiFiCluster]** Add ability to override default authorizers.xml template. +- [PR #96](https://github.com/konpyutaika/nifikop/pull/96) - **[Operator/NifiCluster]** Add ability to specify pod priority class ### Changed