From 37ade9075a40ee1144d96ce32a380ad6e03a1f89 Mon Sep 17 00:00:00 2001 From: Simon Mayer Date: Mon, 24 Aug 2026 08:44:30 +0200 Subject: [PATCH 1/3] Add command for monitoring credentials --- cmd/admin/v1/cluster.go | 38 +++++++++++++++++++++++++++++++- cmd/api/v1/cluster.go | 23 ++++++++++++++++--- docs/metal_cluster.md | 2 +- docs/metal_cluster_monitoring.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 6 files changed, 62 insertions(+), 9 deletions(-) diff --git a/cmd/admin/v1/cluster.go b/cmd/admin/v1/cluster.go index f21b196..ded0181 100644 --- a/cmd/admin/v1/cluster.go +++ b/cmd/admin/v1/cluster.go @@ -115,9 +115,29 @@ func newClusterCmd(c *config.Config) *cobra.Command { Short: "commands for cluster machines", } + // metal admin cluster monitoring + monitoringCmd := &cobra.Command{ + Use: "monitoring", + Short: "fetch endpoint and access credentials for cluster monitoring", + RunE: func(cmd *cobra.Command, args []string) error { + id, err := genericcli.GetExactlyOneArg(args) + if err != nil { + return err + } + + clusterMonitoring, err := w.getMonitoringCredentials(id) + if err != nil { + return err + } + + return c.DescribePrinter.Print(clusterMonitoring) + }, + ValidArgsFunction: c.Completion.AdminClusterListCompletion, + } + machineCmd.AddCommand(machineListCmd, machineSSHCmd) - return genericcli.NewCmds(cmdsConfig, kubeconfigCmd, machineCmd) + return genericcli.NewCmds(cmdsConfig, kubeconfigCmd, machineCmd, monitoringCmd) } func (c *cluster) Create(rq any) (*apiv1.Cluster, error) { @@ -221,6 +241,22 @@ func (c *cluster) kubeconfig(args []string) error { return nil } +func (c *cluster) getMonitoringCredentials(id string) (*apiv1.ClusterMonitoring, error) { + ctx, cancel := c.c.NewRequestContext() + defer cancel() + + req := &adminv1.ClusterServiceGetMonitoringCredentialsRequest{ + Uuid: id, + } + + resp, err := c.c.Client.Adminv1().Cluster().GetMonitoringCredentials(ctx, connect.NewRequest(req)) + if err != nil { + return nil, fmt.Errorf("failed to get cluster credentials: %w", err) + } + + return resp.Msg.Monitoring, nil +} + func (c *cluster) machineList(args []string) error { ctx, cancel := c.c.NewRequestContext() defer cancel() diff --git a/cmd/api/v1/cluster.go b/cmd/api/v1/cluster.go index 9773626..7b05add 100644 --- a/cmd/api/v1/cluster.go +++ b/cmd/api/v1/cluster.go @@ -144,19 +144,19 @@ func newClusterCmd(c *config.Config) *cobra.Command { monitoringCmd := &cobra.Command{ Use: "monitoring", - Short: "fetch endpoints and access credentials to cluster monitoring", + Short: "fetch endpoint and access credentials for cluster monitoring", RunE: func(cmd *cobra.Command, args []string) error { id, err := genericcli.GetExactlyOneArg(args) if err != nil { return err } - cluster, err := w.Get(id) + clusterMonitoring, err := w.getMonitoringCredentials(id) if err != nil { return err } - return c.DescribePrinter.Print(cluster.Monitoring) + return c.DescribePrinter.Print(clusterMonitoring) }, ValidArgsFunction: c.Completion.ClusterListCompletion, } @@ -319,6 +319,23 @@ func (c *cluster) Get(id string) (*apiv1.Cluster, error) { return resp.Msg.Cluster, nil } +func (c *cluster) getMonitoringCredentials(id string) (*apiv1.ClusterMonitoring, error) { + ctx, cancel := c.c.NewRequestContext() + defer cancel() + + req := &apiv1.ClusterServiceGetMonitoringCredentialsRequest{ + Uuid: id, + Project: c.c.GetProject(), + } + + resp, err := c.c.Client.Apiv1().Cluster().GetMonitoringCredentials(ctx, connect.NewRequest(req)) + if err != nil { + return nil, fmt.Errorf("failed to get cluster credentials: %w", err) + } + + return resp.Msg.Monitoring, nil +} + func (c *cluster) List() ([]*apiv1.Cluster, error) { ctx, cancel := c.c.NewRequestContext() defer cancel() diff --git a/docs/metal_cluster.md b/docs/metal_cluster.md index b0ce8fb..f8c09f9 100644 --- a/docs/metal_cluster.md +++ b/docs/metal_cluster.md @@ -36,7 +36,7 @@ manage kubernetes clusters * [metal cluster exec-config](metal_cluster_exec-config.md) - fetch exec-config of a cluster * [metal cluster kubeconfig](metal_cluster_kubeconfig.md) - fetch kubeconfig of a cluster * [metal cluster list](metal_cluster_list.md) - list all clusters -* [metal cluster monitoring](metal_cluster_monitoring.md) - fetch endpoints and access credentials to cluster monitoring +* [metal cluster monitoring](metal_cluster_monitoring.md) - fetch endpoint and access credentials for cluster monitoring * [metal cluster reconcile](metal_cluster_reconcile.md) - reconcile a cluster * [metal cluster status](metal_cluster_status.md) - fetch status of a cluster * [metal cluster update](metal_cluster_update.md) - updates the cluster diff --git a/docs/metal_cluster_monitoring.md b/docs/metal_cluster_monitoring.md index 39b5401..f88ea6b 100644 --- a/docs/metal_cluster_monitoring.md +++ b/docs/metal_cluster_monitoring.md @@ -1,6 +1,6 @@ ## metal cluster monitoring -fetch endpoints and access credentials to cluster monitoring +fetch endpoint and access credentials for cluster monitoring ``` metal cluster monitoring [flags] diff --git a/go.mod b/go.mod index acb82f7..6946d23 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/fatih/color v1.19.0 github.com/golang-jwt/jwt/v5 v5.3.1 github.com/google/go-cmp v0.7.0 - github.com/metal-stack-cloud/api v0.16.8 + github.com/metal-stack-cloud/api v0.16.9-0.20260824062944-5e134e2301b8 github.com/metal-stack/metal-lib v0.26.1 github.com/metal-stack/v v1.0.3 github.com/spf13/afero v1.15.0 diff --git a/go.sum b/go.sum index 7e6a3d6..0e9b28a 100644 --- a/go.sum +++ b/go.sum @@ -233,8 +233,8 @@ github.com/mdlayher/sdnotify v1.0.0 h1:Ma9XeLVN/l0qpyx1tNeMSeTjCPH6NtuD6/N9XdTlQ github.com/mdlayher/sdnotify v1.0.0/go.mod h1:HQUmpM4XgYkhDLtd+Uad8ZFK1T9D5+pNxnXQjCeJlGE= github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos= github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ= -github.com/metal-stack-cloud/api v0.16.8 h1:ntXPUkqp1XQRyALWBJxx4zSLhFK/Fa5/HQINQ5iH78I= -github.com/metal-stack-cloud/api v0.16.8/go.mod h1:fct2KsojPKyGgB7bZun42Teb80Pb4LvnMmAOfcco0N0= +github.com/metal-stack-cloud/api v0.16.9-0.20260824062944-5e134e2301b8 h1:MxljlUh9i2ohTfYSHvnHaaNlumuknqkHvcIRvWs2fzE= +github.com/metal-stack-cloud/api v0.16.9-0.20260824062944-5e134e2301b8/go.mod h1:fct2KsojPKyGgB7bZun42Teb80Pb4LvnMmAOfcco0N0= github.com/metal-stack/metal-lib v0.26.1 h1:wMrhENm/HPq0t7cjCkhzepGD6dyxmX/4IMsaJZea874= github.com/metal-stack/metal-lib v0.26.1/go.mod h1:tnx4MM5oml10EMN6Nq6oFSbjOKB9B27WUZQUyZ4MywA= github.com/metal-stack/v v1.0.3 h1:Sh2oBlnxrCUD+mVpzfC8HiqL045YWkxs0gpTvkjppqs= From 6be301f0c3d49710058a8744b2684bc6e7e97da1 Mon Sep 17 00:00:00 2001 From: Simon Mayer Date: Wed, 26 Aug 2026 09:35:53 +0200 Subject: [PATCH 2/3] Regenerate --- go.sum | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/go.sum b/go.sum index 554a7ec..a28dbe4 100644 --- a/go.sum +++ b/go.sum @@ -254,12 +254,10 @@ github.com/mdlayher/netlink v1.11.2 h1:HKh2jqe+omdSWcQ88nrT7INE61B0NXfiSPFdgL4Yb github.com/mdlayher/netlink v1.11.2/go.mod h1:uT2Yc/QLaZubzDpZIBi9d4GoeLwtp3x1AMeqSRrK2sA= github.com/mdlayher/sdnotify v1.0.0 h1:Ma9XeLVN/l0qpyx1tNeMSeTjCPH6NtuD6/N9XdTlQ3c= github.com/mdlayher/sdnotify v1.0.0/go.mod h1:HQUmpM4XgYkhDLtd+Uad8ZFK1T9D5+pNxnXQjCeJlGE= -github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos= -github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ= -github.com/metal-stack-cloud/api v0.16.9-0.20260824062944-5e134e2301b8 h1:MxljlUh9i2ohTfYSHvnHaaNlumuknqkHvcIRvWs2fzE= -github.com/metal-stack-cloud/api v0.16.9-0.20260824062944-5e134e2301b8/go.mod h1:fct2KsojPKyGgB7bZun42Teb80Pb4LvnMmAOfcco0N0= github.com/mdlayher/socket v0.6.1 h1:M7uj2NtuujUY4mYr1C57NmfNiRHbkKpnBxO856lsc3A= github.com/mdlayher/socket v0.6.1/go.mod h1:+/SGtqc9V+5dAuRgQsU0fGBI+oRDiW7O2Obx10OIWfg= +github.com/metal-stack-cloud/api v0.16.9-0.20260824062944-5e134e2301b8 h1:MxljlUh9i2ohTfYSHvnHaaNlumuknqkHvcIRvWs2fzE= +github.com/metal-stack-cloud/api v0.16.9-0.20260824062944-5e134e2301b8/go.mod h1:fct2KsojPKyGgB7bZun42Teb80Pb4LvnMmAOfcco0N0= github.com/metal-stack/metal-lib v0.26.3 h1:K5gLoD65m6p3l6qCPrfavIdvNdWfmF2QdXrvU2URaZs= github.com/metal-stack/metal-lib v0.26.3/go.mod h1:cNXjPBs8SFnjqfBobuSbm5mDk6E/jS8PVeIOrV/7POE= github.com/metal-stack/v v1.0.3 h1:Sh2oBlnxrCUD+mVpzfC8HiqL045YWkxs0gpTvkjppqs= From ace5edb9c116b4feb524ef22c87f959ec9109c3d Mon Sep 17 00:00:00 2001 From: Simon Mayer Date: Wed, 26 Aug 2026 17:04:32 +0200 Subject: [PATCH 3/3] Update go module --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 81511f6..2c841c4 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/fatih/color v1.19.0 github.com/golang-jwt/jwt/v5 v5.3.1 github.com/google/go-cmp v0.7.0 - github.com/metal-stack-cloud/api v0.16.9-0.20260824062944-5e134e2301b8 + github.com/metal-stack-cloud/api v0.16.11-0.20260826143907-4dfc96d1bd98 github.com/metal-stack/metal-lib v0.26.3 github.com/metal-stack/v v1.0.3 github.com/spf13/afero v1.15.0 diff --git a/go.sum b/go.sum index a28dbe4..0a40d09 100644 --- a/go.sum +++ b/go.sum @@ -256,8 +256,8 @@ github.com/mdlayher/sdnotify v1.0.0 h1:Ma9XeLVN/l0qpyx1tNeMSeTjCPH6NtuD6/N9XdTlQ github.com/mdlayher/sdnotify v1.0.0/go.mod h1:HQUmpM4XgYkhDLtd+Uad8ZFK1T9D5+pNxnXQjCeJlGE= github.com/mdlayher/socket v0.6.1 h1:M7uj2NtuujUY4mYr1C57NmfNiRHbkKpnBxO856lsc3A= github.com/mdlayher/socket v0.6.1/go.mod h1:+/SGtqc9V+5dAuRgQsU0fGBI+oRDiW7O2Obx10OIWfg= -github.com/metal-stack-cloud/api v0.16.9-0.20260824062944-5e134e2301b8 h1:MxljlUh9i2ohTfYSHvnHaaNlumuknqkHvcIRvWs2fzE= -github.com/metal-stack-cloud/api v0.16.9-0.20260824062944-5e134e2301b8/go.mod h1:fct2KsojPKyGgB7bZun42Teb80Pb4LvnMmAOfcco0N0= +github.com/metal-stack-cloud/api v0.16.11-0.20260826143907-4dfc96d1bd98 h1:PiM5slGnSAXNUtUML01kRLtN9t/GAxor9qbKKWQt71s= +github.com/metal-stack-cloud/api v0.16.11-0.20260826143907-4dfc96d1bd98/go.mod h1:qVXtruhliCBHisv1u6YXPAFtQrGURel60aVakLQyT4g= github.com/metal-stack/metal-lib v0.26.3 h1:K5gLoD65m6p3l6qCPrfavIdvNdWfmF2QdXrvU2URaZs= github.com/metal-stack/metal-lib v0.26.3/go.mod h1:cNXjPBs8SFnjqfBobuSbm5mDk6E/jS8PVeIOrV/7POE= github.com/metal-stack/v v1.0.3 h1:Sh2oBlnxrCUD+mVpzfC8HiqL045YWkxs0gpTvkjppqs=