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 agent hostNetwork option #1257

Merged
merged 1 commit into from
Oct 19, 2020
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
2 changes: 2 additions & 0 deletions deploy/crds/jaegertracing.io_jaegers_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ spec:
type: object
config:
type: object
hostNetwork:
type: boolean
image:
type: string
imagePullSecrets:
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/jaegertracing/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ type JaegerAgentSpec struct {

// +optional
SidecarSecurityContext *v1.SecurityContext `json:"sidecarSecurityContext,omitempty"`

// +optional
HostNetwork *bool `json:"hostNetwork,omitempty"`
}

// JaegerStorageSpec defines the common storage options to be used for the query and collector
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/jaegertracing/v1/zz_generated.deepcopy.go

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

6 changes: 6 additions & 0 deletions pkg/apis/jaegertracing/v1/zz_generated.openapi.go

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

2 changes: 1 addition & 1 deletion pkg/client/versioned/clientset.go

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

6 changes: 6 additions & 0 deletions pkg/deployment/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ func (a *Agent) Get() *appsv1.DaemonSet {
// see https://github.com/jaegertracing/jaeger-operator/issues/334
sort.Strings(args)

hostNetwork := false
if a.jaeger.Spec.Agent.HostNetwork != nil {
hostNetwork = *a.jaeger.Spec.Agent.HostNetwork
}

return &appsv1.DaemonSet{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Expand Down Expand Up @@ -176,6 +181,7 @@ func (a *Agent) Get() *appsv1.DaemonSet {
Resources: commonSpec.Resources,
VolumeMounts: commonSpec.VolumeMounts,
}},
HostNetwork: hostNetwork,
Volumes: commonSpec.Volumes,
Affinity: commonSpec.Affinity,
Tolerations: commonSpec.Tolerations,
Expand Down
11 changes: 11 additions & 0 deletions pkg/deployment/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,15 @@ func TestAgentServiceLinks(t *testing.T) {
dep := a.Get()
falseVar := false
assert.Equal(t, &falseVar, dep.Spec.Template.Spec.EnableServiceLinks)
assert.Equal(t, falseVar, dep.Spec.Template.Spec.HostNetwork)
}

func TestAgentHostNetwork(t *testing.T) {
trueVar := true
jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"})
jaeger.Spec.Agent.Strategy = "daemonset"
jaeger.Spec.Agent.HostNetwork = &trueVar
a := NewAgent(jaeger)
dep := a.Get()
assert.Equal(t, trueVar, dep.Spec.Template.Spec.HostNetwork)
}