-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kumactl) add install loki for log aggregation
Add the Loki stack to `kumactl install` allowing to see logs directly in Grafana. The yaml for loki was inspired by: `https://grafana.github.io/loki/charts` * Add a new install command to kubectl: `kubectl install logging` * Upgrate Grafana version to 7.0.3 that accepts loki as a data source.
- Loading branch information
Showing
13 changed files
with
1,080 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package install | ||
|
||
import ( | ||
"github.com/Kong/kuma/app/kumactl/pkg/install/data" | ||
"github.com/Kong/kuma/app/kumactl/pkg/install/k8s" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/Kong/kuma/app/kumactl/pkg/install/k8s/logging" | ||
) | ||
|
||
type loggingTemplateArgs struct { | ||
Namespace string | ||
} | ||
|
||
func newInstallLogging() *cobra.Command { | ||
args := struct { | ||
Namespace string | ||
}{ | ||
Namespace: "kuma-logging", | ||
} | ||
cmd := &cobra.Command{ | ||
Use: "logging", | ||
Short: "Install Logging backend in Kubernetes cluster (Loki)", | ||
Long: `Install Logging backend in Kubernetes cluster (Loki) in a 'kuma-logging' namespace`, | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
templateArgs := loggingTemplateArgs{ | ||
Namespace: args.Namespace, | ||
} | ||
|
||
templateFiles, err := data.ReadFiles(logging.Templates) | ||
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 := k8s.SortResourcesByKind(renderedFiles) | ||
|
||
singleFile := data.JoinYAML(sortedResources) | ||
|
||
if _, err := cmd.OutOrStdout().Write(singleFile.Data); err != nil { | ||
return errors.Wrap(err, "Failed to output rendered resources") | ||
} | ||
return nil | ||
}, | ||
} | ||
cmd.Flags().StringVar(&args.Namespace, "namespace", args.Namespace, "namespace to install logging to") | ||
return cmd | ||
} |
Oops, something went wrong.