-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 option to add authentication to Jaeger and custom tags #13728
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -112,7 +112,7 @@ func DefaultEnv(cfg *config.Config) []corev1.EnvVar { | |||
) | ||||
} | ||||
|
||||
func WorkspaceTracingEnv(context *RenderContext) (res []corev1.EnvVar) { | ||||
func WorkspaceTracingEnv(context *RenderContext, component string) (res []corev1.EnvVar) { | ||||
var tracing *experimental.Tracing | ||||
|
||||
_ = context.WithExperimental(func(cfg *experimental.Config) error { | ||||
|
@@ -122,10 +122,10 @@ func WorkspaceTracingEnv(context *RenderContext) (res []corev1.EnvVar) { | |||
return nil | ||||
}) | ||||
|
||||
return tracingEnv(context, tracing) | ||||
return tracingEnv(context, component, tracing) | ||||
} | ||||
|
||||
func WebappTracingEnv(context *RenderContext) (res []corev1.EnvVar) { | ||||
func WebappTracingEnv(context *RenderContext, component string) (res []corev1.EnvVar) { | ||||
var tracing *experimental.Tracing | ||||
|
||||
_ = context.WithExperimental(func(cfg *experimental.Config) error { | ||||
|
@@ -135,10 +135,10 @@ func WebappTracingEnv(context *RenderContext) (res []corev1.EnvVar) { | |||
return nil | ||||
}) | ||||
|
||||
return tracingEnv(context, tracing) | ||||
return tracingEnv(context, component, tracing) | ||||
} | ||||
|
||||
func tracingEnv(context *RenderContext, tracing *experimental.Tracing) (res []corev1.EnvVar) { | ||||
func tracingEnv(context *RenderContext, component string, tracing *experimental.Tracing) (res []corev1.EnvVar) { | ||||
if context.Config.Observability.Tracing == nil { | ||||
res = append(res, corev1.EnvVar{Name: "JAEGER_DISABLED", Value: "true"}) | ||||
return | ||||
|
@@ -154,6 +154,41 @@ func tracingEnv(context *RenderContext, tracing *experimental.Tracing) (res []co | |||
// but would make env var composition more cumbersome. | ||||
} | ||||
|
||||
if context.Config.Observability.Tracing.SecretName != nil { | ||||
res = append(res, corev1.EnvVar{ | ||||
Name: "JAEGER_USER", | ||||
ValueFrom: &corev1.EnvVarSource{SecretKeyRef: &corev1.SecretKeySelector{ | ||||
LocalObjectReference: corev1.LocalObjectReference{Name: *context.Config.Observability.Tracing.SecretName}, | ||||
Key: "JAEGER_USER", | ||||
}}, | ||||
}) | ||||
|
||||
res = append(res, corev1.EnvVar{ | ||||
Name: "JAEGER_PASSWORD", | ||||
ValueFrom: &corev1.EnvVarSource{SecretKeyRef: &corev1.SecretKeySelector{ | ||||
LocalObjectReference: corev1.LocalObjectReference{Name: *context.Config.Observability.Tracing.SecretName}, | ||||
Key: "JAEGER_PASSWORD", | ||||
}}, | ||||
}) | ||||
} | ||||
Comment on lines
+157
to
+173
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we expose these as ENV variables? In general, mounting the secret as a volume is preferred for credentials and here we could do that if the SecretName is specified. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's how the library is configured.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could construct that manually, from the information we mount - https://pkg.go.dev/github.com/uber/jaeger-client-go/config#Configuration I'll raise an issue as a follow-up (which will likely never get done) as I don't want to block your change but we do abuse env variables a fair bit. |
||||
|
||||
res = append(res, corev1.EnvVar{Name: "JAEGER_SERVICE_NAME", Value: component}) | ||||
|
||||
jaegerTags := []string{} | ||||
if context.Config.Metadata.InstallationShortname != "" { | ||||
jaegerTags = append(jaegerTags, fmt.Sprintf("cluster=%v", context.Config.Metadata.InstallationShortname)) | ||||
} | ||||
|
||||
if context.Config.Metadata.Region != "" { | ||||
jaegerTags = append(jaegerTags, fmt.Sprintf("region=%v", context.Config.Metadata.Region)) | ||||
} | ||||
|
||||
if len(jaegerTags) > 0 { | ||||
res = append(res, | ||||
corev1.EnvVar{Name: "JAEGER_TAGS", Value: strings.Join(jaegerTags, ",")}, | ||||
) | ||||
} | ||||
|
||||
samplerType := experimental.TracingSampleTypeConst | ||||
samplerParam := "1" | ||||
|
||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this indirection here if we're actually keeping them the same? Could we instead consolidate on
func TracingEnv(...)
. If the need for these to actually be different arises, we can refactor.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know the reason.
ping @mrsimonemms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing to do with me I'm afraid. This was added by @andrew-farries around 5 months ago - 1119e55