Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion cmd/admin/v1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,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) {
Expand Down Expand Up @@ -242,6 +262,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()
Expand Down
23 changes: 20 additions & 3 deletions cmd/api/v1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,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,
}
Expand Down Expand Up @@ -322,6 +322,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()
Expand Down
2 changes: 1 addition & 1 deletion docs/metal_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/metal_cluster_monitoring.md
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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 h1:biSqJ1BI3ExRbZD4Oz5z0SoO9b8T9uvrRSZrYtZDfco=
github.com/metal-stack-cloud/api v0.16.9/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=
Expand Down