diff --git a/examples/agent-with-priority-class.yaml b/examples/agent-with-priority-class.yaml new file mode 100644 index 000000000..b9407805c --- /dev/null +++ b/examples/agent-with-priority-class.yaml @@ -0,0 +1,16 @@ +apiVersion: scheduling.k8s.io/v1 +kind: PriorityClass +metadata: + name: high-priority # priorityClassName here +value: 1000000 +globalDefault: false +description: "This priority class should be used for XYZ service pods only." +--- +apiVersion: jaegertracing.io/v1 +kind: Jaeger +metadata: + name: agent-as-daemonset +spec: + agent: + strategy: DaemonSet + PriorityClassName: high-priority # priorityClassName here \ No newline at end of file diff --git a/pkg/apis/jaegertracing/v1/jaeger_types.go b/pkg/apis/jaegertracing/v1/jaeger_types.go index 1ab1dd91c..4404fbab8 100644 --- a/pkg/apis/jaegertracing/v1/jaeger_types.go +++ b/pkg/apis/jaegertracing/v1/jaeger_types.go @@ -452,6 +452,9 @@ type JaegerAgentSpec struct { // +optional HostNetwork *bool `json:"hostNetwork,omitempty"` + + // +optional + PriorityClassName string `json:"priorityClassName,omitempty"` } // JaegerStorageSpec defines the common storage options to be used for the query and collector diff --git a/pkg/apis/jaegertracing/v1/zz_generated.openapi.go b/pkg/apis/jaegertracing/v1/zz_generated.openapi.go index a0b33fd7a..7ded93c85 100644 --- a/pkg/apis/jaegertracing/v1/zz_generated.openapi.go +++ b/pkg/apis/jaegertracing/v1/zz_generated.openapi.go @@ -346,6 +346,12 @@ func schema_pkg_apis_jaegertracing_v1_JaegerAgentSpec(ref common.ReferenceCallba Format: "", }, }, + "priorityClassName": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, }, }, }, diff --git a/pkg/deployment/agent.go b/pkg/deployment/agent.go index 4210ddbda..06c167b68 100644 --- a/pkg/deployment/agent.go +++ b/pkg/deployment/agent.go @@ -85,7 +85,10 @@ func (a *Agent) Get() *appsv1.DaemonSet { if a.jaeger.Spec.Agent.HostNetwork != nil { hostNetwork = *a.jaeger.Spec.Agent.HostNetwork } - + priorityClassName := "" + if a.jaeger.Spec.Agent.PriorityClassName != "" { + priorityClassName = a.jaeger.Spec.Agent.PriorityClassName + } return &appsv1.DaemonSet{ TypeMeta: metav1.TypeMeta{ APIVersion: "apps/v1", @@ -171,6 +174,7 @@ func (a *Agent) Get() *appsv1.DaemonSet { VolumeMounts: commonSpec.VolumeMounts, }}, HostNetwork: hostNetwork, + PriorityClassName: priorityClassName, Volumes: commonSpec.Volumes, Affinity: commonSpec.Affinity, Tolerations: commonSpec.Tolerations, diff --git a/pkg/deployment/agent_test.go b/pkg/deployment/agent_test.go index 3ee93701c..bea856836 100644 --- a/pkg/deployment/agent_test.go +++ b/pkg/deployment/agent_test.go @@ -245,3 +245,13 @@ func TestAgentHostNetwork(t *testing.T) { dep := a.Get() assert.Equal(t, trueVar, dep.Spec.Template.Spec.HostNetwork) } + +func TestAgentPriorityClassName(t *testing.T) { + priorityClassName := "test-class" + jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"}) + jaeger.Spec.Agent.Strategy = "daemonset" + jaeger.Spec.Agent.PriorityClassName = priorityClassName + a := NewAgent(jaeger) + dep := a.Get() + assert.Equal(t, priorityClassName, dep.Spec.Template.Spec.PriorityClassName) +}