Skip to content

Commit

Permalink
Add option to add authentication to Jaeger and custom tags
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Oct 10, 2022
1 parent 1c01d58 commit 21b5d2e
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 15 deletions.
45 changes: 40 additions & 5 deletions install/installer/pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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",
}},
})
}

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"

Expand Down
2 changes: 1 addition & 1 deletion install/installer/pkg/components/agent-smith/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) {
}},
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
common.DefaultEnv(&ctx.Config),
common.WorkspaceTracingEnv(ctx),
common.WorkspaceTracingEnv(ctx, Component),
common.NodeNameEnv(ctx),
)),
SecurityContext: &corev1.SecurityContext{
Expand Down
2 changes: 1 addition & 1 deletion install/installer/pkg/components/blobserve/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
},
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
common.DefaultEnv(&ctx.Config),
common.WorkspaceTracingEnv(ctx),
common.WorkspaceTracingEnv(ctx, Component),
)),
VolumeMounts: []corev1.VolumeMount{{
Name: "config",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
},
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
common.DefaultEnv(&ctx.Config),
common.WorkspaceTracingEnv(ctx),
common.WorkspaceTracingEnv(ctx, Component),
[]corev1.EnvVar{{
Name: "GRPC_GO_RETRY",
Value: "on",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
},
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
common.DefaultEnv(&ctx.Config),
common.WorkspaceTracingEnv(ctx),
common.WorkspaceTracingEnv(ctx, Component),
)),
Resources: common.ResourceRequirements(ctx, Component, Component, corev1.ResourceRequirements{
Requests: corev1.ResourceList{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) {
},
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
common.DefaultEnv(&ctx.Config),
common.WorkspaceTracingEnv(ctx),
common.WorkspaceTracingEnv(ctx, Component),
[]corev1.EnvVar{
{
Name: "GRPC_GO_RETRY",
Expand Down
2 changes: 1 addition & 1 deletion install/installer/pkg/components/server/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
env := common.MergeEnv(
common.DefaultEnv(&ctx.Config),
common.DatabaseEnv(&ctx.Config),
common.WebappTracingEnv(ctx),
common.WebappTracingEnv(ctx, Component),
common.AnalyticsEnv(&ctx.Config),
common.MessageBusEnv(&ctx.Config),
common.ConfigcatEnv(ctx),
Expand Down
2 changes: 1 addition & 1 deletion install/installer/pkg/components/ws-daemon/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ fi
}},
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
common.DefaultEnv(&cfg),
common.WorkspaceTracingEnv(ctx),
common.WorkspaceTracingEnv(ctx, Component),
common.NodeNameEnv(ctx),
)),
Resources: common.ResourceRequirements(ctx, Component, Component, corev1.ResourceRequirements{Requests: corev1.ResourceList{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
},
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
common.DefaultEnv(&ctx.Config),
common.WorkspaceTracingEnv(ctx),
common.WorkspaceTracingEnv(ctx, Component),
common.AnalyticsEnv(&ctx.Config),
common.MessageBusEnv(&ctx.Config),
common.DatabaseEnv(&ctx.Config),
Expand Down
2 changes: 1 addition & 1 deletion install/installer/pkg/components/ws-manager/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
},
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
common.DefaultEnv(&ctx.Config),
common.WorkspaceTracingEnv(ctx),
common.WorkspaceTracingEnv(ctx, Component),
[]corev1.EnvVar{{Name: "GRPC_GO_RETRY", Value: "on"}},
)),
VolumeMounts: []corev1.VolumeMount{
Expand Down
2 changes: 1 addition & 1 deletion install/installer/pkg/components/ws-proxy/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
},
Env: common.CustomizeEnvvar(ctx, Component, common.MergeEnv(
common.DefaultEnv(&ctx.Config),
common.WorkspaceTracingEnv(ctx),
common.WorkspaceTracingEnv(ctx, Component),
common.AnalyticsEnv(&ctx.Config),
)),
ReadinessProbe: &corev1.Probe{
Expand Down
3 changes: 3 additions & 0 deletions install/installer/pkg/config/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ type Analytics struct {
type Tracing struct {
Endpoint *string `json:"endpoint,omitempty"`
AgentHost *string `json:"agentHost,omitempty"`
// Name of the kubernetes secret to use for Jaeger authentication
// The secret should contains two definitions: JAEGER_USER and JAEGER_PASSWORD
SecretName *string `json:"secretName,omitempty"`
}

type Database struct {
Expand Down

0 comments on commit 21b5d2e

Please sign in to comment.