Improve the cmd: get clusters#449
Conversation
… internal IP. Created a help function to create globally a kube client. cnoe-io#445 Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
|
If several clusters/contexts/nodes have been created, then the command will output the following information: |
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
|
I refactored the code to show the clusters using a Table |
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
There was a problem hiding this comment.
Once the static password PR merges, we could merge these into the util package. No action needed for this PR imo
pkg/cmd/get/clusters.go
Outdated
| c, found := findClusterByName(config, "kind-"+cluster) | ||
| if !found { | ||
| //logger.Error(nil, fmt.Sprintf("Cluster not found: %s within kube config file\n", cluster)) | ||
| return nil, err |
There was a problem hiding this comment.
Log and continue here instead? Even if client doesn't exist for some reason, we can find other valid clusters.
There was a problem hiding this comment.
Yes. This is better to continue and to log a message. See: 031e81b
| //logger.Error(err, "failed to get the allocated resources.") | ||
| return nil, err | ||
| } | ||
| aNode.Allocated = allocated |
There was a problem hiding this comment.
Are we doing anything with aNode? Looks like it's discarded each iteration?
There was a problem hiding this comment.
Good question. Do we want part of the command "get clusters" to also show the allocated or available resources OR this is something that we will only show when we will display the detail of a cluster ?
There was a problem hiding this comment.
Hmm it would be nice to have but I'd say it's not critical since you can get that information with kubectl describe nodes command.
There was a problem hiding this comment.
The big plus of our command is that we could show everything with one command (= developer like that) in one place vs running several kubectl commands ;-)
There was a problem hiding this comment.
I don't see aNode value used for anything here still.
There was a problem hiding this comment.
Added a new column to list the nodes
NAME EXTERNAL-PORT KUBE-API TLS KUBE-PORT NODES
my-konflux 8443 https://127.0.0.1:57063 false 6443 my-konflux-control-plane
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
…ubeconfig file BUT we log a message Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
|
Can we merge it ? @nabuskey |
pkg/cmd/get/clusters.go
Outdated
|
|
||
| detectOpt, err := util.DetectKindNodeProvider() | ||
| if err != nil { | ||
| //logger.Error(err, "failed to detect the provider.") |
There was a problem hiding this comment.
remove commented out logger message like this
There was a problem hiding this comment.
Removed the comments.
pkg/cmd/root.go
Outdated
| func init() { | ||
| rootCmd.PersistentFlags().StringVarP(&helpers.LogLevel, "log-level", "l", "info", helpers.LogLevelMsg) | ||
| rootCmd.PersistentFlags().BoolVar(&helpers.ColoredOutput, "color", false, helpers.ColoredOutputMsg) | ||
| rootCmd.PersistentFlags().StringVarP(&helpers.KubeConfigPath, "kubeconfig", "", "", "kube config file Path.") |
There was a problem hiding this comment.
This is not good. This means kubeconfig flag is available to ALL commands. While this is desirable in the future, this is not supported by all commands yet. This is going to cause a lot of confusions.
Either:
- Move this to the get cluster command only. OR
- Remove this flag entirely and do this in a separate PR.
There was a problem hiding this comment.
I moved the flag to the get command: See: dffda70
| service := corev1.Service{} | ||
| namespacedName := types.NamespacedName{ | ||
| Name: "kubernetes", | ||
| Namespace: "default", | ||
| } | ||
| err := cli.Get(context.TODO(), namespacedName, &service) | ||
| if err != nil { | ||
| return 0, fmt.Errorf("failed to get the kubernetes default service on the cluster. %w", err) | ||
| } |
There was a problem hiding this comment.
I think it's better to look at the localbuild object instead.
I see you are doing port.Name != "" && strings.HasPrefix(port.Name, "https"). But this is not guaranteed to be available. For example, if you run the create command with --protocol http, the https port returned is incorrect.
So I'd rather look at the spec.buildCustomization field of the localbuild object.
idpbuilder/api/v1alpha1/localbuild_types.go
Lines 52 to 59 in 03559e6
pkg/cmd/get/clusters.go
Outdated
| // Display the total allocated resources | ||
| //fmt.Printf(" CPU Requests: %s\n", totalCPU.String()) | ||
| //fmt.Printf(" Memory Requests: %s\n", totalMemory.String()) | ||
|
|
| //logger.Error(err, "failed to get the allocated resources.") | ||
| return nil, err | ||
| } | ||
| aNode.Allocated = allocated |
There was a problem hiding this comment.
I don't see aNode value used for anything here still.
pkg/cmd/get/clusters.go
Outdated
| } | ||
|
|
||
| // Populate a list of Kube client for each cluster/context matching a idpbuilder cluster | ||
| manager, _ := CreateKubeClientForEachIDPCluster(config, clusters) |
There was a problem hiding this comment.
Need to handle error here. If an error is returned and manager is nil, we will panic.
…of nodes Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
|
/e2e |
Uh oh!
There was an error while loading. Please reload this page.