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

Feat: add NodeSelector to jaeger collector, query, and ingestor #2200

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions apis/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ type JaegerQuerySpec struct {
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Strategy"
Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"`

// +optional
// +nullable
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

// JaegerUISpec defines the options to be used to configure the UI
Expand Down Expand Up @@ -455,6 +459,10 @@ type JaegerCollectorSpec struct {

// +optional
KafkaSecretName string `json:"kafkaSecretName"`

// +optional
// +nullable
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

// JaegerIngesterSpec defines the options to be used when deploying the ingester
Expand Down Expand Up @@ -485,6 +493,10 @@ type JaegerIngesterSpec struct {

// +optional
KafkaSecretName string `json:"kafkaSecretName"`

// +optional
// +nullable
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

// JaegerAgentSpec defines the options to be used when deploying the agent
Expand Down
21 changes: 21 additions & 0 deletions apis/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions bundle/manifests/jaegertracing.io_jaegers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3855,6 +3855,11 @@ spec:
minReplicas:
format: int32
type: integer
nodeSelector:
additionalProperties:
type: string
nullable: true
type: object
options:
type: object
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -5362,6 +5367,11 @@ spec:
minReplicas:
format: int32
type: integer
nodeSelector:
additionalProperties:
type: string
nullable: true
type: object
options:
type: object
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -8307,6 +8317,11 @@ spec:
nodePort:
format: int32
type: integer
nodeSelector:
additionalProperties:
type: string
nullable: true
type: object
options:
type: object
x-kubernetes-preserve-unknown-fields: true
Expand Down
15 changes: 15 additions & 0 deletions config/crd/bases/jaegertracing.io_jaegers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3853,6 +3853,11 @@ spec:
minReplicas:
format: int32
type: integer
nodeSelector:
additionalProperties:
type: string
nullable: true
type: object
options:
type: object
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -5360,6 +5365,11 @@ spec:
minReplicas:
format: int32
type: integer
nodeSelector:
additionalProperties:
type: string
nullable: true
type: object
options:
type: object
x-kubernetes-preserve-unknown-fields: true
Expand Down Expand Up @@ -8305,6 +8315,11 @@ spec:
nodePort:
format: int32
type: integer
nodeSelector:
additionalProperties:
type: string
nullable: true
type: object
options:
type: object
x-kubernetes-preserve-unknown-fields: true
Expand Down
21 changes: 21 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12815,6 +12815,13 @@ Resource Types:
<i>Format</i>: int32<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>nodeSelector</b></td>
<td>map[string]string</td>
<td>
<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>options</b></td>
<td>object</td>
Expand Down Expand Up @@ -18606,6 +18613,13 @@ Resource Types:
<i>Format</i>: int32<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>nodeSelector</b></td>
<td>map[string]string</td>
<td>
<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>options</b></td>
<td>object</td>
Expand Down Expand Up @@ -29858,6 +29872,13 @@ Resource Types:
<i>Format</i>: int32<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>nodeSelector</b></td>
<td>map[string]string</td>
<td>
<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>options</b></td>
<td>object</td>
Expand Down
11 changes: 10 additions & 1 deletion pkg/deployment/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ func (c *Collector) Get() *appsv1.Deployment {
},
}

return &appsv1.Deployment{
var nodeSelector map[string]string
if c.jaeger.Spec.Collector.NodeSelector != nil {
nodeSelector = c.jaeger.Spec.Collector.NodeSelector
}

deployment := &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Kind: "Deployment",
Expand Down Expand Up @@ -226,6 +231,10 @@ func (c *Collector) Get() *appsv1.Deployment {
},
},
}
if nodeSelector != nil {
deployment.Spec.Template.Spec.NodeSelector = nodeSelector
}
return deployment
}

// Services returns a list of services to be deployed along with the all-in-one deployment
Expand Down
13 changes: 13 additions & 0 deletions pkg/deployment/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,3 +814,16 @@ func TestCollectorContainerSecurityContextOverride(t *testing.T) {

assert.Equal(t, overrideSecurityContextVar, *dep.Spec.Template.Spec.Containers[0].SecurityContext)
}

func TestCollectorNodeSelector(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"})
nodeSelector := map[string]string{
"agentpool": "service",
}
jaeger.Spec.Collector.NodeSelector = nodeSelector

c := NewCollector(jaeger)
dep := c.Get()

assert.Equal(t, nodeSelector, dep.Spec.Template.Spec.NodeSelector)
}
11 changes: 10 additions & 1 deletion pkg/deployment/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ func (i *Ingester) Get() *appsv1.Deployment {
livenessProbe = i.jaeger.Spec.Ingester.LivenessProbe
}

return &appsv1.Deployment{
var nodeSelector map[string]string
if i.jaeger.Spec.Ingester.NodeSelector != nil {
nodeSelector = i.jaeger.Spec.Ingester.NodeSelector
}

deployment := &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Kind: "Deployment",
Expand Down Expand Up @@ -190,6 +195,10 @@ func (i *Ingester) Get() *appsv1.Deployment {
},
},
}
if nodeSelector != nil {
deployment.Spec.Template.Spec.NodeSelector = nodeSelector
}
return deployment
}

func (i *Ingester) labels() map[string]string {
Expand Down
13 changes: 13 additions & 0 deletions pkg/deployment/ingester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,3 +618,16 @@ func TestIngesterContainerSecurityContextOverride(t *testing.T) {

assert.Equal(t, overrideSecurityContextVar, *dep.Spec.Template.Spec.Containers[0].SecurityContext)
}

func TestIngesterNodeSelector(t *testing.T) {
jaeger := newIngesterJaeger("my-instance")
nodeSelector := map[string]string{
"agentpool": "service",
}
jaeger.Spec.Ingester.NodeSelector = nodeSelector

i := NewIngester(jaeger)
dep := i.Get()

assert.Equal(t, nodeSelector, dep.Spec.Template.Spec.NodeSelector)
}
11 changes: 10 additions & 1 deletion pkg/deployment/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ func (q *Query) Get() *appsv1.Deployment {
livenessProbe = q.jaeger.Spec.Query.LivenessProbe
}

return &appsv1.Deployment{
var nodeSelector map[string]string
if q.jaeger.Spec.Query.NodeSelector != nil {
nodeSelector = q.jaeger.Spec.Query.NodeSelector
}

deployment := &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Kind: "Deployment",
Expand Down Expand Up @@ -202,6 +207,10 @@ func (q *Query) Get() *appsv1.Deployment {
},
},
}
if nodeSelector != nil {
deployment.Spec.Template.Spec.NodeSelector = nodeSelector
}
return deployment
}

// Services returns a list of services to be deployed along with the query deployment
Expand Down
13 changes: 13 additions & 0 deletions pkg/deployment/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,3 +494,16 @@ func TestQueryContainerSecurityContextOverride(t *testing.T) {

assert.Equal(t, overrideSecurityContextVar, *dep.Spec.Template.Spec.Containers[0].SecurityContext)
}

func TestQueryNodeSelector(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"})
nodeSelector := map[string]string{
"agentpool": "service",
}
jaeger.Spec.Query.NodeSelector = nodeSelector

q := NewQuery(jaeger)
dep := q.Get()

assert.Equal(t, nodeSelector, dep.Spec.Template.Spec.NodeSelector)
}