Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PriorityClass for AllInOne strategy #2218

Merged
merged 6 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apis/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ type JaegerAllInOneSpec struct {
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Strategy"
Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"`

// +optional
PriorityClassName string `json:"priorityClassName,omitempty"`
}

// AutoScaleSpec defines the common elements used for create HPAs
Expand Down
2 changes: 2 additions & 0 deletions bundle/manifests/jaegertracing.io_jaegers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2423,6 +2423,8 @@ spec:
options:
type: object
x-kubernetes-preserve-unknown-fields: true
priorityClassName:
type: string
resources:
nullable: true
properties:
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/jaegertracing.io_jaegers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2421,6 +2421,8 @@ spec:
options:
type: object
x-kubernetes-preserve-unknown-fields: true
priorityClassName:
type: string
resources:
nullable: true
properties:
Expand Down
7 changes: 7 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7312,6 +7312,13 @@ Resource Types:
<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>priorityClassName</b></td>
<td>string</td>
<td>
<br/>
</td>
<td>false</td>
</tr><tr>
<td><b><a href="#jaegerspecallinoneresources">resources</a></b></td>
<td>object</td>
Expand Down
17 changes: 17 additions & 0 deletions examples/all-in-one-with-priority-class.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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: "my-jaeger"
spec:
strategy: allInOne
allInOne:
image: jaegertracing/all-in-one:1.30.0
priorityClassName: high-priority # priorityClassName here
6 changes: 6 additions & 0 deletions pkg/deployment/all_in_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ func (a *AllInOne) Get() *appsv1.Deployment {
strategy = *a.jaeger.Spec.AllInOne.Strategy
}

priorityClassName := ""
if a.jaeger.Spec.AllInOne.PriorityClassName != "" {
priorityClassName = a.jaeger.Spec.AllInOne.PriorityClassName
}

livenessProbe := &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Expand Down Expand Up @@ -246,6 +251,7 @@ func (a *AllInOne) Get() *appsv1.Deployment {
ImagePullPolicy: commonSpec.ImagePullPolicy,
SecurityContext: commonSpec.ContainerSecurityContext,
}},
PriorityClassName: priorityClassName,
Volumes: commonSpec.Volumes,
ServiceAccountName: account.JaegerServiceAccountFor(a.jaeger, account.AllInOneComponent),
Affinity: commonSpec.Affinity,
Expand Down
9 changes: 9 additions & 0 deletions pkg/deployment/all_in_one_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,15 @@ func TestAllInOneContainerSecurityContextOverride(t *testing.T) {
assert.Equal(t, overrideSecurityContextVar, *dep.Spec.Template.Spec.Containers[0].SecurityContext)
}

func TestAllInOnePriorityClassName(t *testing.T) {
priorityClassName := "test-class"
jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"})
jaeger.Spec.AllInOne.PriorityClassName = priorityClassName
a := NewAllInOne(jaeger)
dep := a.Get()
assert.Equal(t, priorityClassName, dep.Spec.Template.Spec.PriorityClassName)
}

func getEnvVarByName(vars []corev1.EnvVar, name string) corev1.EnvVar {
envVar := corev1.EnvVar{}
for _, v := range vars {
Expand Down