-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d2adc5b
Showing
12 changed files
with
1,744 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# IntelliJ config | ||
.idea/ | ||
|
||
# Build artifact | ||
kubectl-actuator-plugin |
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 @@ | ||
¯\_(ツ)_/¯ |
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,50 @@ | ||
# kubectl-actuator-plugin | ||
|
||
## Purpose | ||
|
||
This kubectl cli plugin enables you to interact with the Spring Boot Actuator component. | ||
|
||
## Functionality | ||
|
||
Retrieving the logger configuration if an application: | ||
``` | ||
❯ kubectl actuator logger get --pod ms-aks-dev-ms-asset-manager-66d5ff5f66-czp7w | ||
LOGGER LEVEL | ||
ROOT INFO | ||
com.azure.core.amqp WARN | ||
com.azure.messaging.eventhubs WARN | ||
com.deviceinsight.ms INFO | ||
org.apache.catalina.startup.DigesterFactory ERROR | ||
org.apache.catalina.util.LifecycleBase ERROR | ||
org.apache.coyote.http11.Http11NioProtocol WARN | ||
org.apache.sshd.common.util.SecurityUtils WARN | ||
org.apache.tomcat.util.net.NioSelectorPool WARN | ||
org.eclipse.jetty.util.component.AbstractLifeCycle ERROR | ||
org.hibernate.validator.internal.util.Version WARN | ||
org.springframework.boot.actuate.endpoint.jmx WARN | ||
``` | ||
|
||
Setting the level of a logger: | ||
``` | ||
❯ kubectl actuator logger set --pod ms-aks-dev-ms-asset-manager-66d5ff5f66-czp7w com.deviceinsight.ms INFO | ||
``` | ||
|
||
## Installation | ||
Right now there is no binary build available, so you have to build the plugin yourself: | ||
|
||
``` | ||
❯ git clone git@gitlab.device-insight.com:mwa/kubectl-actuator-plugin.git | ||
❯ cd kubectl-actuator-plugin/ | ||
❯ go build | ||
❯ cp -p kubectl-actuator-plugin ~/.local/bin/kubectl-actuator | ||
❯ kubectl actuator --help | ||
``` | ||
|
||
## TODO | ||
* Code cleanup | ||
* Investigate why command line completion is not working | ||
* Provide autocomplete support for logger and log levels | ||
* Validate log level options | ||
* Support deployments and statefulsets | ||
* Make Actuator port and URL configurable via pod labels | ||
* Support other actuator components |
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,42 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
"gitlab.device-insight.com/mwa/kubectl-actuator-plugin/pkg/cmd" | ||
"k8s.io/cli-runtime/pkg/genericclioptions" | ||
"os" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "kubectl-actuator", | ||
Short: "Control your Spring Boot applications via Actuator", | ||
} | ||
|
||
var loggerCmd = &cobra.Command{ | ||
Use: "logger", | ||
Short: "Inspect and manipulate your applications loggers", | ||
} | ||
|
||
func Execute() { | ||
err := rootCmd.Execute() | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func init() { | ||
configFlags := genericclioptions.NewConfigFlags(true) | ||
|
||
// Add k8s config flags and hide them | ||
configFlags.AddFlags(rootCmd.PersistentFlags()) | ||
rootCmd.PersistentFlags().VisitAll(func(flag *pflag.Flag) { | ||
flag.Hidden = true | ||
}) | ||
|
||
rootCmd.AddCommand(loggerCmd) | ||
loggerCmd.AddCommand( | ||
cmd.NewLoggerGetCommand(configFlags), | ||
cmd.NewLoggerSetCommand(configFlags), | ||
) | ||
} |
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,75 @@ | ||
module gitlab.device-insight.com/mwa/kubectl-actuator-plugin | ||
|
||
go 1.17 | ||
|
||
require ( | ||
github.com/go-resty/resty/v2 v2.7.0 | ||
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de | ||
github.com/pkg/errors v0.9.1 | ||
github.com/spf13/cobra v1.3.0 | ||
github.com/spf13/pflag v1.0.5 | ||
k8s.io/api v0.0.0-20220114212057-37c9308dad1e | ||
k8s.io/apimachinery v0.0.0-20220114211744-3c16f3dcfb0b | ||
k8s.io/cli-runtime v0.0.0-20220114215615-28aad093b364 | ||
k8s.io/client-go v0.0.0-20220114212508-092b54e6e535 | ||
) | ||
|
||
require ( | ||
github.com/PuerkitoBio/purell v1.1.1 // indirect | ||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/evanphx/json-patch v4.12.0+incompatible // indirect | ||
github.com/go-errors/errors v1.0.1 // indirect | ||
github.com/go-logr/logr v1.2.0 // indirect | ||
github.com/go-openapi/jsonpointer v0.19.5 // indirect | ||
github.com/go-openapi/jsonreference v0.19.5 // indirect | ||
github.com/go-openapi/swag v0.19.14 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/google/btree v1.0.1 // indirect | ||
github.com/google/gofuzz v1.1.0 // indirect | ||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect | ||
github.com/google/uuid v1.1.2 // indirect | ||
github.com/googleapis/gnostic v0.5.5 // indirect | ||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect | ||
github.com/imdario/mergo v0.3.5 // indirect | ||
github.com/inconshreveable/mousetrap v1.0.0 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/mailru/easyjson v0.7.6 // indirect | ||
github.com/moby/spdystream v0.2.0 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect | ||
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/stretchr/testify v1.7.0 // indirect | ||
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect | ||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect | ||
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect | ||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect | ||
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect | ||
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect | ||
google.golang.org/appengine v1.6.7 // indirect | ||
google.golang.org/protobuf v1.27.1 // indirect | ||
gopkg.in/inf.v0 v0.9.1 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect | ||
k8s.io/klog/v2 v2.40.1 // indirect | ||
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect | ||
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 // indirect | ||
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect | ||
sigs.k8s.io/kustomize/api v0.10.1 // indirect | ||
sigs.k8s.io/kustomize/kyaml v0.13.0 // indirect | ||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect | ||
sigs.k8s.io/yaml v1.2.0 // indirect | ||
) | ||
|
||
replace ( | ||
k8s.io/api => k8s.io/api v0.0.0-20220114212057-37c9308dad1e | ||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20220114211744-3c16f3dcfb0b | ||
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20220114215615-28aad093b364 | ||
k8s.io/client-go => k8s.io/client-go v0.0.0-20220114212508-092b54e6e535 | ||
) |
Oops, something went wrong.