diff --git a/deploy/klusterlet/chart/klusterlet/templates/priority_class.yaml b/deploy/klusterlet/chart/klusterlet/templates/priority_class.yaml index 6e4479f50..d6ee3cc31 100644 --- a/deploy/klusterlet/chart/klusterlet/templates/priority_class.yaml +++ b/deploy/klusterlet/chart/klusterlet/templates/priority_class.yaml @@ -1,3 +1,4 @@ +{{- if not .Values.noOperator }} {{- if .Values.priorityClassName }} apiVersion: scheduling.k8s.io/v1 kind: PriorityClass @@ -8,3 +9,4 @@ globalDefault: false description: "This priority class should be used for klusterlet agents only." preemptionPolicy: PreemptLowerPriority {{- end }} +{{- end }} diff --git a/pkg/operator/helpers/chart/render_test.go b/pkg/operator/helpers/chart/render_test.go index 7087bdddc..471ca5379 100644 --- a/pkg/operator/helpers/chart/render_test.go +++ b/pkg/operator/helpers/chart/render_test.go @@ -326,6 +326,20 @@ func TestKlusterletConfig(t *testing.T) { }, expectedObjCnt: 1, }, + { + name: "noOperator with priority cluster", + namespace: "ocm", + chartConfig: func() *KlusterletChartConfig { + config := NewDefaultKlusterletChartConfig() + config.NoOperator = true + config.Klusterlet.Name = "klusterlet2" + config.Klusterlet.Namespace = "open-cluster-management-test" + config.Klusterlet.ClusterName = "testCluster" + config.PriorityClassName = "klusterlet-critical" + return config + }, + expectedObjCnt: 1, + }, { name: "noOperator with image pull secret", namespace: "ocm", @@ -335,6 +349,7 @@ func TestKlusterletConfig(t *testing.T) { config.Klusterlet.Name = "klusterlet2" config.Klusterlet.Namespace = "open-cluster-management-test" config.Klusterlet.ClusterName = "testCluster" + config.PriorityClassName = "klusterlet-critical" config.Images = ImagesConfig{ ImageCredentials: ImageCredentials{ CreateImageCredentials: true, @@ -453,6 +468,9 @@ func TestKlusterletConfig(t *testing.T) { if object.Spec.ClusterName != config.Klusterlet.ClusterName { t.Errorf(" expected %s, got %s", config.Klusterlet.ClusterName, object.Spec.ClusterName) } + if object.Spec.PriorityClassName != config.PriorityClassName { + t.Errorf(" expected %s, got %s", config.PriorityClassName, object.Spec.PriorityClassName) + } switch config.Klusterlet.Mode { case "", operatorv1.InstallModeSingleton, operatorv1.InstallModeDefault: if config.Klusterlet.Mode == "" && object.Spec.DeployOption.Mode != operatorv1.InstallModeSingleton {