From 6acf37a9984b4a6d9d58d3dd99a44ed9dcf796dd Mon Sep 17 00:00:00 2001 From: Simon Kissane Date: Sun, 14 Sep 2025 09:02:07 +1000 Subject: [PATCH 1/2] Add support for standard kubectl tracing I am having a problem with the portforwarding into the pod. Standard approach for debugging these kinds of issues is to pass `-v=9` argument to `kubectl` so I see the actual API traffic dumps in the logs. But `kubectl cost` doesn't support that argument, so there is no way to turn the K8S API client library tracing on. Hence, I have added support for those arguments. --- cmd/kubectl-cost/kubectl-cost.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/kubectl-cost/kubectl-cost.go b/cmd/kubectl-cost/kubectl-cost.go index 9243940..900c3a7 100644 --- a/cmd/kubectl-cost/kubectl-cost.go +++ b/cmd/kubectl-cost/kubectl-cost.go @@ -4,10 +4,13 @@ import ( "os" "k8s.io/cli-runtime/pkg/genericclioptions" + "k8s.io/klog/v2" "github.com/spf13/pflag" "github.com/kubecost/kubectl-cost/pkg/cmd" + + goflag "flag" ) // The following are set by https://github.com/ahmetb/govvv during @@ -27,6 +30,8 @@ type assetsQuery struct { func main() { flags := pflag.NewFlagSet("kubectl-ns", pflag.ExitOnError) pflag.CommandLine = flags + klog.InitFlags(nil) + pflag.CommandLine.AddGoFlagSet(goflag.CommandLine) root := cmd.NewCmdCost( genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}, From c3ea9eccfa340be489662855be65b19d4b9e0e56 Mon Sep 17 00:00:00 2001 From: Simon Kissane Date: Sun, 14 Sep 2025 09:41:10 +1000 Subject: [PATCH 2/2] go.mod: k8s.io/klog/v2 no longer indirect --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 1c2afd0..6cf729b 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( k8s.io/apimachinery v0.32.0 k8s.io/cli-runtime v0.32.0 k8s.io/client-go v0.32.0 + k8s.io/klog/v2 v2.130.1 ) require ( @@ -87,7 +88,6 @@ require ( gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect