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

feat(*): unified installation of metrics/logging/tracing into one command observability #4308

Merged
merged 10 commits into from
May 23, 2022
48 changes: 36 additions & 12 deletions app/kumactl/cmd/completion/testdata/bash.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3789,10 +3789,6 @@ _kumactl_install_logging()
flags_with_completion=()
flags_completion=()

flags+=("--namespace=")
two_word_flags+=("--namespace")
local_nonpersistent_flags+=("--namespace")
local_nonpersistent_flags+=("--namespace=")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -3820,6 +3816,37 @@ _kumactl_install_metrics()
flags_with_completion=()
flags_completion=()

flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
two_word_flags+=("--config-file")
flags+=("--log-level=")
two_word_flags+=("--log-level")
flags+=("--no-config")

must_have_one_flag=()
must_have_one_noun=()
noun_aliases=()
}

_kumactl_install_observability()
{
last_command="kumactl_install_observability"

command_aliases=()

commands=()

flags=()
two_word_flags=()
local_nonpersistent_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--components=")
two_word_flags+=("--components")
local_nonpersistent_flags+=("--components")
local_nonpersistent_flags+=("--components=")
flags+=("--jaeger-address=")
two_word_flags+=("--jaeger-address")
local_nonpersistent_flags+=("--jaeger-address")
Expand All @@ -3839,10 +3866,10 @@ _kumactl_install_metrics()
two_word_flags+=("--namespace")
local_nonpersistent_flags+=("--namespace")
local_nonpersistent_flags+=("--namespace=")
flags+=("--without-grafana")
local_nonpersistent_flags+=("--without-grafana")
flags+=("--without-prometheus")
local_nonpersistent_flags+=("--without-prometheus")
flags+=("--prometheus-address=")
two_word_flags+=("--prometheus-address")
local_nonpersistent_flags+=("--prometheus-address")
local_nonpersistent_flags+=("--prometheus-address=")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -3870,10 +3897,6 @@ _kumactl_install_tracing()
flags_with_completion=()
flags_completion=()

flags+=("--namespace=")
two_word_flags+=("--namespace")
local_nonpersistent_flags+=("--namespace")
local_nonpersistent_flags+=("--namespace=")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -3985,6 +4008,7 @@ _kumactl_install()
commands+=("gateway")
commands+=("logging")
commands+=("metrics")
commands+=("observability")
commands+=("tracing")
commands+=("transparent-proxy")

Expand Down
17 changes: 0 additions & 17 deletions app/kumactl/cmd/install/context/install_logging_context.go

This file was deleted.

36 changes: 0 additions & 36 deletions app/kumactl/cmd/install/context/install_metrics_context.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package context

type Dashboard struct {
FileName string
Content string
}

type ObservabilityTemplateArgs struct {
Namespace string
Mesh string
KumaCpAddress string
JaegerAddress string
LokiAddress string
PrometheusAddress string
KumaCpApiAddress string
Components []string
ComponentsMap map[string]bool
Dashboards []Dashboard
}

type InstallObservabilityContext struct {
TemplateArgs ObservabilityTemplateArgs
}

func DefaultInstallObservabilityContext() InstallObservabilityContext {
return InstallObservabilityContext{
TemplateArgs: ObservabilityTemplateArgs{
Namespace: "mesh-observability",
KumaCpAddress: "http://kuma-control-plane.kuma-system:5676",
KumaCpApiAddress: "http://kuma-control-plane.kuma-system:5681",
JaegerAddress: "http://jaeger-query.mesh-observability",
LokiAddress: "http://loki.mesh-observability:3100",
PrometheusAddress: "http://prometheus-server.mesh-observability",
Components: []string{"grafana", "prometheus", "loki", "jaeger"},
},
}
}
17 changes: 0 additions & 17 deletions app/kumactl/cmd/install/context/install_tracing_context.go

This file was deleted.

7 changes: 4 additions & 3 deletions app/kumactl/cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ func NewInstallCmd(pctx *kumactl_cmd.RootContext) *cobra.Command {
// sub-commands
cmd.AddCommand(newInstallControlPlaneCmd(&pctx.InstallCpContext))
cmd.AddCommand(newInstallCrdsCmd(&pctx.InstallCRDContext))
cmd.AddCommand(newInstallMetrics(pctx))
cmd.AddCommand(newInstallTracing(pctx))
cmd.AddCommand(newInstallLogging(pctx))
cmd.AddCommand(newInstallObservability(pctx))
cmd.AddCommand(newInstallMetrics())
cmd.AddCommand(newInstallTracing())
cmd.AddCommand(newInstallLogging())
cmd.AddCommand(newInstallDemoCmd(&pctx.InstallDemoContext))
cmd.AddCommand(newInstallGatewayCmd(pctx))
cmd.AddCommand(newInstallTransparentProxy())
Expand Down
39 changes: 2 additions & 37 deletions app/kumactl/cmd/install/install_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,16 @@ package install
import (
"github.com/pkg/errors"
"github.com/spf13/cobra"

kumactl_data "github.com/kumahq/kuma/app/kumactl/data"
kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd"
"github.com/kumahq/kuma/app/kumactl/pkg/install/data"
"github.com/kumahq/kuma/app/kumactl/pkg/install/k8s"
)

type loggingTemplateArgs struct {
Namespace string
}

func newInstallLogging(pctx *kumactl_cmd.RootContext) *cobra.Command {
args := pctx.InstallLoggingContext.TemplateArgs
func newInstallLogging() *cobra.Command {
cmd := &cobra.Command{
Use: "logging",
Short: "Install Logging backend in Kubernetes cluster (Loki)",
Long: `Install Logging backend in Kubernetes cluster (Loki) in its own namespace.`,
RunE: func(cmd *cobra.Command, _ []string) error {
templateArgs := loggingTemplateArgs{
Namespace: args.Namespace,
}

templateFiles, err := data.ReadFiles(kumactl_data.InstallLoggingFS())
if err != nil {
return errors.Wrap(err, "Failed to read template files")
}

renderedFiles, err := renderFiles(templateFiles, templateArgs, simpleTemplateRenderer)
if err != nil {
return errors.Wrap(err, "Failed to render template files")
}

sortedResources, err := k8s.SortResourcesByKind(renderedFiles)
if err != nil {
return errors.Wrap(err, "Failed to sort resources by kind")
}

singleFile := data.JoinYAML(sortedResources)

if _, err := cmd.OutOrStdout().Write(singleFile.Data); err != nil {
return errors.Wrap(err, "Failed to output rendered resources")
}
return nil
return errors.New("we're migrating to `observability`, please use `install observability`")
},
}
cmd.Flags().StringVar(&args.Namespace, "namespace", args.Namespace, "namespace to install logging to")
return cmd
}
68 changes: 0 additions & 68 deletions app/kumactl/cmd/install/install_logging_test.go

This file was deleted.

Loading