Skip to content

Commit

Permalink
expose OTLP collector and allInOne ports
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas <[email protected]>
  • Loading branch information
rubenvp8510 committed Jun 16, 2022
1 parent c7244a5 commit 621ae4c
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 34 deletions.
54 changes: 33 additions & 21 deletions pkg/deployment/all_in_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,27 @@ func (a *AllInOne) Get() *appsv1.Deployment {
strategy = *a.jaeger.Spec.AllInOne.Strategy
}

envVars := []corev1.EnvVar{
{
Name: "SPAN_STORAGE_TYPE",
Value: string(a.jaeger.Spec.Storage.Type),
},
{
Name: "METRICS_STORAGE_TYPE",
Value: string(a.jaeger.Spec.AllInOne.MetricsStorage.Type),
},
{
Name: "COLLECTOR_ZIPKIN_HOST_PORT",
Value: ":9411",
},
{
Name: "JAEGER_DISABLED",
Value: strconv.FormatBool(jaegerDisabled),
},
}

envVars = updateOTLPEnvVars(envVars, options)

return &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Expand Down Expand Up @@ -144,27 +165,10 @@ func (a *AllInOne) Get() *appsv1.Deployment {
Spec: corev1.PodSpec{
ImagePullSecrets: commonSpec.ImagePullSecrets,
Containers: []corev1.Container{{
Image: util.ImageName(a.jaeger.Spec.AllInOne.Image, "jaeger-all-in-one-image"),
Name: "jaeger",
Args: options,
Env: []corev1.EnvVar{
{
Name: "SPAN_STORAGE_TYPE",
Value: string(a.jaeger.Spec.Storage.Type),
},
{
Name: "METRICS_STORAGE_TYPE",
Value: string(a.jaeger.Spec.AllInOne.MetricsStorage.Type),
},
{
Name: "COLLECTOR_ZIPKIN_HOST_PORT",
Value: ":9411",
},
{
Name: "JAEGER_DISABLED",
Value: strconv.FormatBool(jaegerDisabled),
},
},
Image: util.ImageName(a.jaeger.Spec.AllInOne.Image, "jaeger-all-in-one-image"),
Name: "jaeger",
Args: options,
Env: envVars,
VolumeMounts: commonSpec.VolumeMounts,
EnvFrom: envFromSource,
Ports: []corev1.ContainerPort{
Expand Down Expand Up @@ -211,6 +215,14 @@ func (a *AllInOne) Get() *appsv1.Deployment {
ContainerPort: 14250,
Name: "grpc",
},
{
ContainerPort: 4317,
Name: "otlp-grpc",
},
{
ContainerPort: 4318,
Name: "otlp-http",
},
},
LivenessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
Expand Down
4 changes: 4 additions & 0 deletions pkg/deployment/all_in_one_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func TestDefaultAllInOneImage(t *testing.T) {
Name: "JAEGER_DISABLED",
Value: "false",
},
{
Name: "COLLECTOR_OTLP_ENABLED",
Value: "true",
},
}
assert.Equal(t, envvars, d.Spec.Template.Spec.Containers[0].Env)
}
Expand Down
38 changes: 25 additions & 13 deletions pkg/deployment/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ func (c *Collector) Get() *appsv1.Deployment {
strategy = *c.jaeger.Spec.Collector.Strategy
}

envVars := []corev1.EnvVar{
{
Name: "SPAN_STORAGE_TYPE",
Value: string(storageType),
},
{
Name: "COLLECTOR_ZIPKIN_HOST_PORT",
Value: ":9411",
},
}

envVars = updateOTLPEnvVars(envVars, options)

return &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Expand Down Expand Up @@ -143,19 +156,10 @@ func (c *Collector) Get() *appsv1.Deployment {
Spec: corev1.PodSpec{
ImagePullSecrets: c.jaeger.Spec.ImagePullSecrets,
Containers: []corev1.Container{{
Image: util.ImageName(c.jaeger.Spec.Collector.Image, "jaeger-collector-image"),
Name: "jaeger-collector",
Args: options,
Env: []corev1.EnvVar{
{
Name: "SPAN_STORAGE_TYPE",
Value: string(storageType),
},
{
Name: "COLLECTOR_ZIPKIN_HOST_PORT",
Value: ":9411",
},
},
Image: util.ImageName(c.jaeger.Spec.Collector.Image, "jaeger-collector-image"),
Name: "jaeger-collector",
Args: options,
Env: envVars,
VolumeMounts: commonSpec.VolumeMounts,
EnvFrom: envFromSource,
Ports: []corev1.ContainerPort{
Expand All @@ -179,6 +183,14 @@ func (c *Collector) Get() *appsv1.Deployment {
ContainerPort: 14250,
Name: "grpc",
},
{
ContainerPort: 4317,
Name: "otlp-grpc",
},
{
ContainerPort: 4318,
Name: "otlp-http",
},
},
LivenessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
Expand Down
16 changes: 16 additions & 0 deletions pkg/deployment/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func TestDefaultCollectorImage(t *testing.T) {
Name: "COLLECTOR_ZIPKIN_HOST_PORT",
Value: ":9411",
},
{
Name: "COLLECTOR_OTLP_ENABLED",
Value: "true",
},
}
assert.Equal(t, envvars, containers[0].Env)
}
Expand Down Expand Up @@ -379,6 +383,10 @@ func TestCollectorWithDirectStorageType(t *testing.T) {
Name: "COLLECTOR_ZIPKIN_HOST_PORT",
Value: ":9411",
},
{
Name: "COLLECTOR_OTLP_ENABLED",
Value: "true",
},
}
assert.Equal(t, envvars, dep.Spec.Template.Spec.Containers[0].Env)
assert.Len(t, dep.Spec.Template.Spec.Containers[0].Args, 2)
Expand Down Expand Up @@ -418,6 +426,10 @@ func TestCollectorWithKafkaStorageType(t *testing.T) {
Name: "COLLECTOR_ZIPKIN_HOST_PORT",
Value: ":9411",
},
{
Name: "COLLECTOR_OTLP_ENABLED",
Value: "true",
},
}
assert.Equal(t, envvars, dep.Spec.Template.Spec.Containers[0].Env)
assert.Len(t, dep.Spec.Template.Spec.Containers[0].Args, 3)
Expand Down Expand Up @@ -453,6 +465,10 @@ func TestCollectorWithIngesterNoOptionsStorageType(t *testing.T) {
Name: "COLLECTOR_ZIPKIN_HOST_PORT",
Value: ":9411",
},
{
Name: "COLLECTOR_OTLP_ENABLED",
Value: "true",
},
}
assert.Equal(t, envvars, dep.Spec.Template.Spec.Containers[0].Env)
assert.Len(t, dep.Spec.Template.Spec.Containers[0].Args, 2)
Expand Down
29 changes: 29 additions & 0 deletions pkg/deployment/otlp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package deployment

import (
"github.com/jaegertracing/jaeger-operator/pkg/util"
corev1 "k8s.io/api/core/v1"
)

const collectorOTLPEnvVarName = "COLLECTOR_OTLP_ENABLED"

func updateOTLPEnvVars(envs []corev1.EnvVar, options []string) []corev1.EnvVar {
noExplicitFlag := len(util.FindItem("--collector.otlp.enabled=", options)) == 0
noExplicitEnvVar := findEnvVar(envs, collectorOTLPEnvVarName) == nil
if noExplicitFlag && noExplicitEnvVar {
envs = append(envs, corev1.EnvVar{
Name: collectorOTLPEnvVarName,
Value: "true",
})
}
return envs
}

func findEnvVar(envs []corev1.EnvVar, name string) *corev1.EnvVar {
for _, env := range envs {
if env.Name == name {
return &env
}
}
return nil
}
8 changes: 8 additions & 0 deletions pkg/service/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ func collectorService(jaeger *v1.Jaeger, selector map[string]string) *corev1.Ser
Name: "http-c-binary-trft",
Port: 14268,
},
{
Name: "otlp-grpc",
Port: 4317,
},
{
Name: "otlp-http",
Port: 4318,
},
},
},
}
Expand Down

0 comments on commit 621ae4c

Please sign in to comment.