feat: add cluster management commands#413
Conversation
| func NewClusterCommand() *cli.Command { | ||
| return &cli.Command{ | ||
| Name: "cluster", | ||
| Usage: "Manage clusters for Kubara", |
There was a problem hiding this comment.
| Usage: "Manage clusters for Kubara", | |
| Usage: "Manage your kubara cluster configurations", |
| 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{} | ||
| } |
There was a problem hiding this comment.
| 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 | |
| } |
| currentConfig := configStore.GetConfig() | ||
|
|
||
| clusters := currentConfig.Clusters | ||
| hubCluster := findHubCluster(clusters) |
There was a problem hiding this comment.
| hubCluster := findHubCluster(clusters) | |
| hubCluster := findHubCluster(clusters) | |
| if hubCluster == nil { | |
| return fmt.Errorf("no hub cluster can be found in config") | |
| } |
There was a problem hiding this comment.
removed code snippet
| clusters := currentConfig.Clusters | ||
| hubCluster := findHubCluster(clusters) | ||
|
|
||
| //create new cluster and append it |
There was a problem hiding this comment.
| //create new cluster and append it | |
| // create new cluster using hub cluster as its dereferenced template |
There was a problem hiding this comment.
removed code snippet
| //create new cluster and append it | ||
| newCluster := hubCluster | ||
| newCluster.Name = spokeName | ||
| newCluster.Type = "spoke" |
There was a problem hiding this comment.
Please introduce an enum for the cluster type in src/internal/config/types.go and use that
| spokeServices := maps.Clone(newCluster.Services) | ||
| newCluster.Services = disableServicesFor(spokeServices, []string{"homer-dashboard", "argocd"}) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
function now applies the catalog to the newly created spoke cluster
| func AddCluster(configFilePath string, spokeName string) error { | ||
|
|
| // 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{}) |
There was a problem hiding this comment.
| // 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
There was a problem hiding this comment.
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.
| Usage: "Create a new spoke cluster for the hub", | ||
| UsageText: "kubara cluster add <cluster-name>", |
There was a problem hiding this comment.
| 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>", |
There was a problem hiding this comment.
Changed description.
| 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", |
There was a problem hiding this comment.
| Description: "Adds a new spoke cluster to the existing hub cluster", | |
| Description: "Adds a new spoke cluster to an existing config yaml", |
There was a problem hiding this comment.
changed description.
| Name: "cluster", | ||
| Usage: "Manage clusters for Kubara", | ||
| UsageText: "kubara cluster [command]", | ||
| Description: "Enables handling for hub and spoke clusters", |
There was a problem hiding this comment.
| Description: "Enables handling for hub and spoke clusters", | |
| Description: "Enables the configuration and quick setup of clusters", |
In order for this to work one needs to place the necessary config secrets in the secret store for argocd to find them
6e8b3d1 to
afa35bb
Compare
a5dca95 to
55feed6
Compare
55feed6 to
30188ab
Compare
📝 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
🧪 Testing
🔗 Related Issues / Tickets
Addresses #346
✅ Checklist
📎 Additional Context (optional)