Skip to content

feat: add cluster management commands#413

Draft
davrad wants to merge 8 commits into
mainfrom
feat/add-cluster-cmd
Draft

feat: add cluster management commands#413
davrad wants to merge 8 commits into
mainfrom
feat/add-cluster-cmd

Conversation

@davrad

@davrad davrad commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

📝 Summary

Draft:
This MR adds a new command: cluster, to work better with multi cluster setups
In addtion this MR (will fix) fixes some bugs

🧩 Type of change

  • 🔧 CLI / Go code
  • 📦 Helm chart
  • 🧱 Terraform module
  • 📝 Documentation
  • 🧪 Test or CI change
  • ♻️ Refactor / cleanup

⚠️ Is this a breaking change?

  • Yes, this change breaks existing functionality (explain in summary)

🧪 Testing

  • CI passed
  • Manually tested (local/dev cluster)
  • Unit tested
  • Not tested (explain why below)

🔗 Related Issues / Tickets

Addresses #346

✅ Checklist

  • Code compiles and passes all tests
  • Linting and style checks pass
  • Comments added for complex logic
  • Documentation updated (if applicable)

📎 Additional Context (optional)

Comment thread src/cmd/cluster/add.go
Comment thread src/cmd/cluster/list.go
Comment thread src/cmd/cluster/cluster.go Outdated
func NewClusterCommand() *cli.Command {
return &cli.Command{
Name: "cluster",
Usage: "Manage clusters for Kubara",

@tuunit tuunit Jun 15, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Usage: "Manage clusters for Kubara",
Usage: "Manage your kubara cluster configurations",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the info

Comment thread src/internal/cmd/cluster/add.go Outdated
Comment on lines +40 to +49
func findHubCluster(clusters []config.Cluster) config.Cluster {
for _, cluster := range clusters {
if cluster.Type == "hub" {
return cluster
}
}
// base case, only necessary for compiler,
// should not execute in a default environment
return config.Cluster{}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func findHubCluster(clusters []config.Cluster) config.Cluster {
for _, cluster := range clusters {
if cluster.Type == "hub" {
return cluster
}
}
// base case, only necessary for compiler,
// should not execute in a default environment
return config.Cluster{}
}
func findHubCluster(clusters []config.Cluster) *config.Cluster {
for _, cluster := range clusters {
if cluster.Type == "hub" {
return &cluster
}
}
return nil
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed code

Comment thread src/internal/cmd/cluster/add.go Outdated
currentConfig := configStore.GetConfig()

clusters := currentConfig.Clusters
hubCluster := findHubCluster(clusters)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hubCluster := findHubCluster(clusters)
hubCluster := findHubCluster(clusters)
if hubCluster == nil {
return fmt.Errorf("no hub cluster can be found in config")
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed code snippet

Comment thread src/internal/cmd/cluster/add.go Outdated
clusters := currentConfig.Clusters
hubCluster := findHubCluster(clusters)

//create new cluster and append it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//create new cluster and append it
// create new cluster using hub cluster as its dereferenced template

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed code snippet

Comment thread src/internal/cmd/cluster/add.go Outdated
//create new cluster and append it
newCluster := hubCluster
newCluster.Name = spokeName
newCluster.Type = "spoke"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please introduce an enum for the cluster type in src/internal/config/types.go and use that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

introduced enum

Comment thread src/internal/cmd/cluster/add.go Outdated
Comment on lines +29 to +30
spokeServices := maps.Clone(newCluster.Services)
newCluster.Services = disableServicesFor(spokeServices, []string{"homer-dashboard", "argocd"})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mhhh i get why you did this but we need to generalize this using the catalog processing logic and instead of cloning the services from the hub we need to use the catalog provided and apply the defaults from the catalog. especially as some of the services can have a filter that they aren't applicable for spoke cluster types

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function now applies the catalog to the newly created spoke cluster

Comment thread src/internal/cmd/cluster/add.go Outdated
Comment on lines +12 to +13
func AddCluster(configFilePath string, spokeName string) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove remove empty line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed empty line

Comment on lines +12 to +17
// Internal Function for the 'kubara cluster ls' command
// Requires the configFilePath for the ConfigStore
// Prints out the context in tabular form
func ListClusters(configFilePath string) error {

configStore := config.NewConfigStoreWithCatalog(configFilePath, catalog.LoadOptions{})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Internal Function for the 'kubara cluster ls' command
// Requires the configFilePath for the ConfigStore
// Prints out the context in tabular form
func ListClusters(configFilePath string) error {
configStore := config.NewConfigStoreWithCatalog(configFilePath, catalog.LoadOptions{})
func ListClusters(configFilePath string) error {
configStore := config.NewConfigStoreWithCatalog(configFilePath, catalog.LoadOptions{})

i think this is self explanatory and doesn't need a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think, that it is self explanatory. As someone who has not worked with the library before and who was not familiar with the cmd structure of the project a single comment like this helps explain to me, how the project works with this.
However I do agree that three lines are a bit too much and have removed two lines.

@tuunit tuunit changed the title Feat/add cluster cmd feat: add cluster management commands Jun 18, 2026
Comment thread src/cmd/cluster/add.go Outdated
Comment on lines +18 to +19
Usage: "Create a new spoke cluster for the hub",
UsageText: "kubara cluster add <cluster-name>",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Usage: "Create a new spoke cluster for the hub",
UsageText: "kubara cluster add <cluster-name>",
Usage: "Add a new spoke cluster to your config",
UsageText: "kubara cluster add <cluster-name>",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed description.

Comment thread src/cmd/cluster/add.go Outdated
Name: "add",
Usage: "Create a new spoke cluster for the hub",
UsageText: "kubara cluster add <cluster-name>",
Description: "Adds a new spoke cluster to the existing hub cluster",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Description: "Adds a new spoke cluster to the existing hub cluster",
Description: "Adds a new spoke cluster to an existing config yaml",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed description.

Comment thread src/cmd/cluster/cluster.go Outdated
Name: "cluster",
Usage: "Manage clusters for Kubara",
UsageText: "kubara cluster [command]",
Description: "Enables handling for hub and spoke clusters",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Description: "Enables handling for hub and spoke clusters",
Description: "Enables the configuration and quick setup of clusters",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed description

@davrad davrad force-pushed the feat/add-cluster-cmd branch from 6e8b3d1 to afa35bb Compare June 19, 2026 09:59
@davrad davrad force-pushed the feat/add-cluster-cmd branch 2 times, most recently from a5dca95 to 55feed6 Compare June 19, 2026 12:47
@davrad davrad force-pushed the feat/add-cluster-cmd branch from 55feed6 to 30188ab Compare June 19, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants