From 00672a70e462d63305e2fd7e247c1af4f5d14de5 Mon Sep 17 00:00:00 2001 From: kelly-gao Date: Thu, 12 Feb 2026 20:40:32 -0500 Subject: [PATCH 01/12] Add PriorityClassName to RC types, CustomizePodSpec, and BaseComponent interface Added getter --- api/v1/runtimecomponent_types.go | 8 ++++++++ common/types.go | 1 + utils/utils.go | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/api/v1/runtimecomponent_types.go b/api/v1/runtimecomponent_types.go index 2b889bfc1..50b928c6c 100644 --- a/api/v1/runtimecomponent_types.go +++ b/api/v1/runtimecomponent_types.go @@ -168,6 +168,10 @@ type RuntimeComponentSpec struct { // The list of hostnames and IPs that will be injected into the application pod's hosts file // +operator-sdk:csv:customresourcedefinitions:order=30,type=spec,displayName="Host Aliases" HostAliases *[]corev1.HostAlias `json:"hostAliases,omitempty"` + + // Name of the PriorityClass for the pod. + // +operator-sdk:csv:customresourcedefinitions:order=31,type=spec,displayName="Priority Class Name" + PriorityClassName *string `json:"priorityClassName,omitempty"` } // Defines the DNS @@ -1107,6 +1111,10 @@ func (cr *RuntimeComponent) GetHostAliases() *[]corev1.HostAlias { return cr.Spec.HostAliases } +func (cr *RuntimeComponent) GetPriorityClassName() *string { + return cr.Spec.PriorityClassName +} + // Initialize the RuntimeComponent instance func (cr *RuntimeComponent) Initialize() { if cr.Spec.PullPolicy == nil { diff --git a/common/types.go b/common/types.go index 350123abd..0417d90fa 100644 --- a/common/types.go +++ b/common/types.go @@ -264,4 +264,5 @@ type BaseComponent interface { GetDNS() BaseComponentDNS GetDisableTopologyRouting() *bool GetHostAliases() *[]corev1.HostAlias + GetPriorityClassName() *string } diff --git a/utils/utils.go b/utils/utils.go index e6a0d413c..3b44e4968 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -767,6 +767,10 @@ func CustomizePodSpec(pts *corev1.PodTemplateSpec, ba common.BaseComponent) { } pts.Spec.Tolerations = ba.GetTolerations() + + if ba.GetPriorityClassName() != nil { + pts.Spec.PriorityClassName = *ba.GetPriorityClassName() + } } // Initialize an empty TopologySpreadConstraints list and optionally prefers scheduling across zones/hosts for pods with podMatchLabels From 71db6f6e2d3895e31640523f74beb61bad8571ba Mon Sep 17 00:00:00 2001 From: kelly-gao Date: Wed, 4 Mar 2026 16:28:50 -0500 Subject: [PATCH 02/12] priortiyClass example added --- examples/priorityclass/01-priorityclass.yaml | 7 ++++ .../priorityclass/02-runtimecomponent.yaml | 42 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 examples/priorityclass/01-priorityclass.yaml create mode 100644 examples/priorityclass/02-runtimecomponent.yaml diff --git a/examples/priorityclass/01-priorityclass.yaml b/examples/priorityclass/01-priorityclass.yaml new file mode 100644 index 000000000..14182cee4 --- /dev/null +++ b/examples/priorityclass/01-priorityclass.yaml @@ -0,0 +1,7 @@ +apiVersion: scheduling.k8s.io/v1 +kind: PriorityClass +metadata: + name: service-critical +value: 1000000 +globalDefault: false +description: "Reserved for critical workloads. Pods with this class may preempt lower-priority pods during resource contention. Pods are Priority 0 by default." \ No newline at end of file diff --git a/examples/priorityclass/02-runtimecomponent.yaml b/examples/priorityclass/02-runtimecomponent.yaml new file mode 100644 index 000000000..6024ef036 --- /dev/null +++ b/examples/priorityclass/02-runtimecomponent.yaml @@ -0,0 +1,42 @@ +apiVersion: rc.app.stacks/v1 +kind: RuntimeComponent +metadata: + name: payment-service +spec: + applicationImage: icr.io/appcafe/open-liberty/samples/getting-started@sha256:80a28b6a71ec02369cc13f621e4 + manageTLS: true + resources: + limits: + cpu: 500m + memory: 1Gi + requests: + cpu: 200m + memory: 512Mi + replicas: 2 + priorityClassName: service-critical + service: + port: 9443 + serviceAccount: + mountToken: true + probes: + startup: + failureThreshold: 12 + periodSeconds: 5 + httpGet: + path: /health/started + port: 9443 + readiness: + httpGet: + path: /health/ready + port: 9443 + initialDelaySeconds: 1 + periodSeconds: 5 + failureThreshold: 24 + liveness: + httpGet: + path: /health/live + port: 9443 + initialDelaySeconds: 8 + periodSeconds: 5 + + From 8909626b2ebcf2b403f10baa56801bff4111fb82 Mon Sep 17 00:00:00 2001 From: kelly-gao Date: Thu, 5 Mar 2026 20:09:10 -0500 Subject: [PATCH 03/12] update example sample image --- examples/priorityclass/02-runtimecomponent.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/priorityclass/02-runtimecomponent.yaml b/examples/priorityclass/02-runtimecomponent.yaml index 6024ef036..289cd9711 100644 --- a/examples/priorityclass/02-runtimecomponent.yaml +++ b/examples/priorityclass/02-runtimecomponent.yaml @@ -3,7 +3,7 @@ kind: RuntimeComponent metadata: name: payment-service spec: - applicationImage: icr.io/appcafe/open-liberty/samples/getting-started@sha256:80a28b6a71ec02369cc13f621e4 + applicationImage: icr.io/appcafe/open-liberty/samples/getting-started@sha256:80a28b6a71ec02369cc13f621e4c3cca0d63b1977be76e15dabbfba48411107f manageTLS: true resources: limits: From 709be92eb4bf07a2834339a265a6856b3b2475d5 Mon Sep 17 00:00:00 2001 From: kelly-gao Date: Mon, 9 Mar 2026 11:26:34 -0400 Subject: [PATCH 04/12] Added TestCustomizePodSpecPriorityClassName to unit tests --- utils/utils_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/utils/utils_test.go b/utils/utils_test.go index a3d58bb82..cfb1f762d 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -494,6 +494,33 @@ func TestCustomizePodSpecServiceLinks(t *testing.T) { verifyTests(testCPS, t) } +func TestCustomizePodSpecPriorityClassName(t *testing.T) { + logger := zap.New() + logf.SetLogger(logger) + + spec := appstacksv1.RuntimeComponentSpec{ + ApplicationImage: appImage, + Service: service, + } + + pts, runtime := &corev1.PodTemplateSpec{}, createRuntimeComponent(name, namespace, spec) + CustomizePodSpec(pts, runtime) + nilResult := pts.Spec.PriorityClassName + + priorityClassName := "high-priority" + spec.PriorityClassName = &priorityClassName + pts, runtime = &corev1.PodTemplateSpec{}, createRuntimeComponent(name, namespace, spec) + CustomizePodSpec(pts, runtime) + setResult := pts.Spec.PriorityClassName + + testCPS := []Test{ + {"Default PriorityClassName", "", nilResult}, + {"Set PriorityClassName", priorityClassName, setResult}, + } + verifyTests(testCPS, t) + +} + func TestCustomizePersistence(t *testing.T) { logger := zap.New() logf.SetLogger(logger) From cb0c1de6d5a4e02a2d03b2e65d934479fde579c1 Mon Sep 17 00:00:00 2001 From: kelly-gao Date: Mon, 9 Mar 2026 13:16:06 -0400 Subject: [PATCH 05/12] Change clearing behaviour --- utils/utils.go | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/utils.go b/utils/utils.go index 3b44e4968..750e07218 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -768,6 +768,7 @@ func CustomizePodSpec(pts *corev1.PodTemplateSpec, ba common.BaseComponent) { pts.Spec.Tolerations = ba.GetTolerations() + pts.Spec.PriorityClassName = "" if ba.GetPriorityClassName() != nil { pts.Spec.PriorityClassName = *ba.GetPriorityClassName() } From 8a8861d098d17791acba42277521f9792524ecb8 Mon Sep 17 00:00:00 2001 From: kelly-gao Date: Mon, 9 Mar 2026 13:46:14 -0400 Subject: [PATCH 06/12] Added clearing to unit tets --- utils/utils_test.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/utils/utils_test.go b/utils/utils_test.go index cfb1f762d..ade25f0e9 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -505,20 +505,27 @@ func TestCustomizePodSpecPriorityClassName(t *testing.T) { pts, runtime := &corev1.PodTemplateSpec{}, createRuntimeComponent(name, namespace, spec) CustomizePodSpec(pts, runtime) - nilResult := pts.Spec.PriorityClassName + defaultPriorityClassName := pts.Spec.PriorityClassName priorityClassName := "high-priority" spec.PriorityClassName = &priorityClassName pts, runtime = &corev1.PodTemplateSpec{}, createRuntimeComponent(name, namespace, spec) CustomizePodSpec(pts, runtime) - setResult := pts.Spec.PriorityClassName + setPriorityClassName := pts.Spec.PriorityClassName + + spec.PriorityClassName = nil + pts = &corev1.PodTemplateSpec{} + pts.Spec.PriorityClassName = priorityClassName + runtime = createRuntimeComponent(name, namespace, spec) + CustomizePodSpec(pts, runtime) + clearPriorityClassName := pts.Spec.PriorityClassName testCPS := []Test{ - {"Default PriorityClassName", "", nilResult}, - {"Set PriorityClassName", priorityClassName, setResult}, + {"Default PriorityClassName (not set)", "", defaultPriorityClassName}, + {"Set PriorityClassName", priorityClassName, setPriorityClassName}, + {"Clearing PriorityClassName", "", clearPriorityClassName}, } verifyTests(testCPS, t) - } func TestCustomizePersistence(t *testing.T) { From 835321271b7e67b39a717204cfe9ab542d68eff9 Mon Sep 17 00:00:00 2001 From: miuponn Date: Wed, 18 Mar 2026 08:02:12 -0700 Subject: [PATCH 07/12] Update manifets, crd, bundle etc --- api/v1/zz_generated.deepcopy.go | 5 +++++ bundle/manifests/rc.app.stacks_runtimecomponents.yaml | 3 +++ .../manifests/runtime-component.clusterserviceversion.yaml | 3 +++ config/crd/bases/rc.app.stacks_runtimecomponents.yaml | 3 +++ internal/deploy/kubectl/runtime-component-crd.yaml | 3 +++ .../deploy/kustomize/daily/base/runtime-component-crd.yaml | 3 +++ 6 files changed, 20 insertions(+) diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index ca62123d2..69f61cdb5 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -697,6 +697,11 @@ func (in *RuntimeComponentSpec) DeepCopyInto(out *RuntimeComponentSpec) { } } } + 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 RuntimeComponentSpec. diff --git a/bundle/manifests/rc.app.stacks_runtimecomponents.yaml b/bundle/manifests/rc.app.stacks_runtimecomponents.yaml index 1407a9aec..0b3f49bc4 100644 --- a/bundle/manifests/rc.app.stacks_runtimecomponents.yaml +++ b/bundle/manifests/rc.app.stacks_runtimecomponents.yaml @@ -4590,6 +4590,9 @@ spec: is allowed from. type: object type: object + priorityClassName: + description: Name of the PriorityClass for the pod. + type: string probes: description: Define health checks on application container to determine whether it is alive or ready to receive traffic diff --git a/bundle/manifests/runtime-component.clusterserviceversion.yaml b/bundle/manifests/runtime-component.clusterserviceversion.yaml index 50695e155..76d8b96e5 100644 --- a/bundle/manifests/runtime-component.clusterserviceversion.yaml +++ b/bundle/manifests/runtime-component.clusterserviceversion.yaml @@ -422,6 +422,9 @@ spec: application pod's hosts file displayName: Host Aliases path: hostAliases + - description: Name of the PriorityClass for the pod. + displayName: Priority Class Name + path: priorityClassName - description: Labels to set on ServiceMonitor. displayName: Monitoring Labels path: monitoring.labels diff --git a/config/crd/bases/rc.app.stacks_runtimecomponents.yaml b/config/crd/bases/rc.app.stacks_runtimecomponents.yaml index e2a9489a2..1dc093f9f 100644 --- a/config/crd/bases/rc.app.stacks_runtimecomponents.yaml +++ b/config/crd/bases/rc.app.stacks_runtimecomponents.yaml @@ -4586,6 +4586,9 @@ spec: is allowed from. type: object type: object + priorityClassName: + description: Name of the PriorityClass for the pod. + type: string probes: description: Define health checks on application container to determine whether it is alive or ready to receive traffic diff --git a/internal/deploy/kubectl/runtime-component-crd.yaml b/internal/deploy/kubectl/runtime-component-crd.yaml index 741c46fa6..42636b780 100644 --- a/internal/deploy/kubectl/runtime-component-crd.yaml +++ b/internal/deploy/kubectl/runtime-component-crd.yaml @@ -4589,6 +4589,9 @@ spec: is allowed from. type: object type: object + priorityClassName: + description: Name of the PriorityClass for the pod. + type: string probes: description: Define health checks on application container to determine whether it is alive or ready to receive traffic diff --git a/internal/deploy/kustomize/daily/base/runtime-component-crd.yaml b/internal/deploy/kustomize/daily/base/runtime-component-crd.yaml index 741c46fa6..42636b780 100644 --- a/internal/deploy/kustomize/daily/base/runtime-component-crd.yaml +++ b/internal/deploy/kustomize/daily/base/runtime-component-crd.yaml @@ -4589,6 +4589,9 @@ spec: is allowed from. type: object type: object + priorityClassName: + description: Name of the PriorityClass for the pod. + type: string probes: description: Define health checks on application container to determine whether it is alive or ready to receive traffic From 1aef7eb69b58d010792c101d4d17a783518ddfd1 Mon Sep 17 00:00:00 2001 From: miuponn Date: Wed, 18 Mar 2026 13:13:09 -0700 Subject: [PATCH 08/12] Added x-descriptor to csv --- bundle/manifests/runtime-component.clusterserviceversion.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bundle/manifests/runtime-component.clusterserviceversion.yaml b/bundle/manifests/runtime-component.clusterserviceversion.yaml index 76d8b96e5..d0c01ed16 100644 --- a/bundle/manifests/runtime-component.clusterserviceversion.yaml +++ b/bundle/manifests/runtime-component.clusterserviceversion.yaml @@ -425,6 +425,8 @@ spec: - description: Name of the PriorityClass for the pod. displayName: Priority Class Name path: priorityClassName + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:text - description: Labels to set on ServiceMonitor. displayName: Monitoring Labels path: monitoring.labels From bfec24f952340f3e1776beb6ce1eb2382a4adc77 Mon Sep 17 00:00:00 2001 From: miuponn Date: Wed, 18 Mar 2026 13:45:47 -0700 Subject: [PATCH 09/12] Expose priorityclass for knative service --- utils/utils.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/utils.go b/utils/utils.go index 750e07218..e39b01210 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -1019,6 +1019,11 @@ func CustomizeKnativeService(ksvc *servingv1.Service, ba common.BaseComponent) { } else { ksvc.Spec.Template.Spec.AutomountServiceAccountToken = nil } + + kvsc.Spec.Template.Spec.PriorityClassName = "" + if ba.GetPriorityClassName() != nil { + kvsc.Spec.Template.Spec.PriorityClassName = *ba.GetPriorityClassName() + } } // CustomizeHPA for autoscaling/v2 From 85b7cf08e702dfda51c9bccfa81783be507b08b5 Mon Sep 17 00:00:00 2001 From: miuponn Date: Thu, 19 Mar 2026 13:01:08 -0700 Subject: [PATCH 10/12] Fixed typo for ksvc spec --- utils/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index e39b01210..bf6373cf8 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -1020,9 +1020,9 @@ func CustomizeKnativeService(ksvc *servingv1.Service, ba common.BaseComponent) { ksvc.Spec.Template.Spec.AutomountServiceAccountToken = nil } - kvsc.Spec.Template.Spec.PriorityClassName = "" + ksvc.Spec.Template.Spec.PriorityClassName = "" if ba.GetPriorityClassName() != nil { - kvsc.Spec.Template.Spec.PriorityClassName = *ba.GetPriorityClassName() + ksvc.Spec.Template.Spec.PriorityClassName = *ba.GetPriorityClassName() } } From 1c13247cd1c27c96248d4aa66d97c13c527fc754 Mon Sep 17 00:00:00 2001 From: miuponn Date: Thu, 9 Apr 2026 09:13:41 -0700 Subject: [PATCH 11/12] Updated user doc --- doc/user-guide-v1.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/user-guide-v1.adoc b/doc/user-guide-v1.adoc index 221fbe9ec..d40809633 100755 --- a/doc/user-guide-v1.adoc +++ b/doc/user-guide-v1.adoc @@ -152,6 +152,7 @@ Each `RuntimeComponent` CR must at least specify the `.spec.applicationImage` fi | `networkPolicy.disable` | A Boolean to disable the creation of the network policy. The default value is `false`. By default, network policies for an application are created and limit incoming traffic. | `networkPolicy.fromLabels` | The labels of one or more pods from which incoming traffic is allowed. | `networkPolicy.namespaceLabels` | The labels of namespaces from which incoming traffic is allowed. +| `priorityClassName` | The name of the PriorityClass to assign to the application pod. PriorityClasses define the scheduling priority and preemption behaviour of pods. For examples, see link:++https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/++[Pod Priority and Preemption]. | `probes` | Defines health checks on an application container to determine whether it is alive or ready to receive traffic. For examples, see link:++https://github.com/OpenLiberty/open-liberty-operator/blob/main/doc/user-guide-v1.adoc#configure-probes++[Configure probes]. | `probes.liveness` | A YAML object configuring the link:++https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-http-request++[Kubernetes liveness probe] that controls when Kubernetes needs to restart the pod. | `probes.readiness` | A YAML object configuring the link:++https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes++[Kubernetes readiness probe] that controls when the pod is ready to receive traffic. From 48339d635b4b24ce69a1f8920fd49b56a72a5262 Mon Sep 17 00:00:00 2001 From: miuponn Date: Thu, 9 Apr 2026 10:00:40 -0700 Subject: [PATCH 12/12] Updated source csv --- .../bases/runtime-component.clusterserviceversion.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/manifests/bases/runtime-component.clusterserviceversion.yaml b/config/manifests/bases/runtime-component.clusterserviceversion.yaml index 4f62bbf5e..dfe4ce485 100644 --- a/config/manifests/bases/runtime-component.clusterserviceversion.yaml +++ b/config/manifests/bases/runtime-component.clusterserviceversion.yaml @@ -367,6 +367,9 @@ spec: path: monitoring.endpoints x-descriptors: - urn:alm:descriptor:com.tectonic.ui:endpointList + - description: Name of the PriorityClass for the pod. + displayName: Priority Class Name + path: priorityClassName - description: Tolerations to be added to application pods. Tolerations allow the scheduler to schedule pods on nodes with matching taints. displayName: Tolerations