Skip to content

Commit

Permalink
feat(kuma-dp): support setting Envoy's --component-log-level (#8241)
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
  • Loading branch information
michaelbeaumont committed Nov 3, 2023
1 parent 1ee1fa1 commit 14f8225
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/kuma-dp/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ func newRunCmd(opts kuma_cmd.RunCmdOpts, rootCtx *RootContext) *cobra.Command {
cmd.PersistentFlags().StringVarP(&cfg.DataplaneRuntime.ResourcePath, "dataplane-file", "d", "", "Path to Dataplane template to apply (YAML or JSON)")
cmd.PersistentFlags().StringToStringVarP(&cfg.DataplaneRuntime.ResourceVars, "dataplane-var", "v", map[string]string{}, "Variables to replace Dataplane template")
cmd.PersistentFlags().StringVar(&cfg.DataplaneRuntime.EnvoyLogLevel, "envoy-log-level", "", "Envoy log level. Available values are: [trace][debug][info][warning|warn][error][critical][off]. By default it inherits Kuma DP logging level.")
cmd.PersistentFlags().StringVar(&cfg.DataplaneRuntime.EnvoyComponentLogLevel, "envoy-component-log-level", "", "Configures Envoy's --component-log-level")
cmd.PersistentFlags().StringVar(&cfg.DataplaneRuntime.Metrics.CertPath, "metrics-cert-path", cfg.DataplaneRuntime.Metrics.CertPath, "A path to the certificate for metrics listener")
cmd.PersistentFlags().StringVar(&cfg.DataplaneRuntime.Metrics.KeyPath, "metrics-key-path", cfg.DataplaneRuntime.Metrics.KeyPath, "A path to the certificate key for metrics listener")
cmd.PersistentFlags().BoolVar(&cfg.DNS.Enabled, "dns-enabled", cfg.DNS.Enabled, "If true then builtin DNS functionality is enabled and CoreDNS server is started")
Expand Down
4 changes: 4 additions & 0 deletions app/kuma-dp/pkg/dataplane/envoy/envoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ func (e *Envoy) Start(stop <-chan struct{}) error {
"--log-level", e.opts.Config.DataplaneRuntime.EnvoyLogLevel,
}

if e.opts.Config.DataplaneRuntime.EnvoyComponentLogLevel != "" {
args = append(args, "--component-log-level", e.opts.Config.DataplaneRuntime.EnvoyComponentLogLevel)
}

// If the concurrency is explicit, use that. On Linux, users
// can also implicitly set concurrency using cpusets.
if e.opts.Config.DataplaneRuntime.Concurrency > 0 {
Expand Down
1 change: 1 addition & 0 deletions docs/generated/cmd/kuma-dp/kuma-dp_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ kuma-dp run [flags]
--dns-prometheus-port uint32 A port for exposing Prometheus stats (default 19153)
--dns-server-config-dir string Directory in which DNS Server config will be generated
--drain-time duration drain time for Envoy connections on Kuma DP shutdown (default 30s)
--envoy-component-log-level string Configures Envoy's --component-log-level
--envoy-log-level string Envoy log level. Available values are: [trace][debug][info][warning|warn][error][critical][off]. By default it inherits Kuma DP logging level.
-h, --help help for run
--mesh string Mesh that Dataplane belongs to
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/app/kuma-dp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ type DataplaneRuntime struct {
// Available values are: [trace][debug][info][warning|warn][error][critical][off]
// By default it inherits Kuma DP logging level.
EnvoyLogLevel string `json:"envoyLogLevel,omitempty" envconfig:"kuma_dataplane_runtime_envoy_log_level"`
// EnvoyComponentLogLevel configures Envoy's --component-log-level and uses
// the exact same syntax: https://www.envoyproxy.io/docs/envoy/latest/operations/cli#cmdoption-component-log-level
EnvoyComponentLogLevel string `json:"envoyComponentLogLevel,omitempty" envconfig:"kuma_dataplane_runtime_envoy_component_log_level"`
// Resources defines the resources for this proxy.
Resources DataplaneResources `json:"resources,omitempty"`
// SocketDir dir to store socket used between Envoy and the dp process
Expand Down
6 changes: 6 additions & 0 deletions pkg/plugins/runtime/k8s/containers/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ func (i *DataplaneProxyFactory) sidecarEnvVars(mesh string, podAnnotations map[s
Value: logLevel,
}
}
if complogLevel, exist := metadata.Annotations(podAnnotations).GetString(metadata.KumaEnvoyComponentLogLevel); exist {
envVars["KUMA_DATAPLANE_RUNTIME_ENVOY_COMPONENT_LOG_LEVEL"] = kube_core.EnvVar{
Name: "KUMA_DATAPLANE_RUNTIME_ENVOY_COMPONENT_LOG_LEVEL",
Value: complogLevel,
}
}

// override defaults with cfg env vars
for envName, envVal := range i.ContainerConfig.EnvVars {
Expand Down
3 changes: 2 additions & 1 deletion pkg/plugins/runtime/k8s/metadata/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ const (

// KumaEnvoyLogLevel allows to control Envoy log level.
// Available values are: [trace][debug][info][warning|warn][error][critical][off]
KumaEnvoyLogLevel = "kuma.io/envoy-log-level"
KumaEnvoyLogLevel = "kuma.io/envoy-log-level"
KumaEnvoyComponentLogLevel = "kuma.io/envoy-component-log-level"

// KumaMetricsPrometheusAggregatePath allows to specify which path for specific app should request for metrics
KumaMetricsPrometheusAggregatePath = "prometheus.metrics.kuma.io/aggregate-%s-path"
Expand Down

0 comments on commit 14f8225

Please sign in to comment.