feat: add Deployment and Service columns to kubectl get spinapps -o wide#473
feat: add Deployment and Service columns to kubectl get spinapps -o wide#473Achanandhi-M wants to merge 2 commits intospinframework:mainfrom
Conversation
Signed-off-by: Achanandhi-M <achanandhi.m@gmail.com>
There was a problem hiding this comment.
Thanks @Achanandhi-M, this looks great. Posting as a general comment for now to allow other core Spin Operator contributors to chime in.
I had a thought around perhaps updating how we consume the values for the deployment and service names in the future in case the naming convention were to change, but today since the app name is used for both, this works well (and my idea might not even be feasible 😄).
Another quick thought: would it be worth adding test coverage for this new output? I'm wondering if the default e2e test might be an eligible place to put new validations? It could also be a follow-up we can create, since it might involve a bit more learning about the test harness, etc.
Signed-off-by: Achanandhi-M <achanandhi.m@gmail.com>
|
Hi @vdice, thank you for the feedback and the brainstorm! I have updated the PR to follow your suggestions:
I've verified the logic with unit tests and regenerated the manifests. Let me know what you think! |
vdice
left a comment
There was a problem hiding this comment.
@Achanandhi-M thanks so much for diving in further to make these recent updates! This is looking really good. I had a few more thoughts when you get a chance.
|
|
||
| // Set the active scheduler | ||
| app.Status.ActiveScheduler = app.Spec.Executor | ||
| app.Status.DeploymentName = app.Name |
There was a problem hiding this comment.
I think we should move this line further below, when we know the Deployment actually exists, probably here.
Then, we can update this line to be: app.Status.DeploymentName = deployment.Name.
| // Set the active scheduler | ||
| app.Status.ActiveScheduler = app.Spec.Executor | ||
| app.Status.DeploymentName = app.Name | ||
| app.Status.ServiceName = app.Name |
There was a problem hiding this comment.
Although this function calls r.findDeploymentForApp to get the Deployment resource for an app (which we can then extract the name from), we don't yet have an r.findServiceForApp to get the name of the service directly.
Would you like to take a crack at adding such a function and calling it here, so that we can set eg app.Status.ServiceName = service.Name? Alternatively, I would also be happy to relegate to a follow-up, eg:
# TODO: find Service resource for this app and set to 'service.Name'
app.Status.ServiceName = app.Name
| t.Fatalf("Failed to get spinapp: %s", err) | ||
| } | ||
|
|
||
| if app.Status.DeploymentName != testSpinAppName { |
There was a problem hiding this comment.
For this check and the service check below, I'm thinking it would be better to check the actual resources directly. Both the Deployment and the Service will have a Label with the corresponding app name, eg core.spinkube.dev/app-name=simple-spinapp, so we should be able to utilize the K8s client to fetch these and then compare to the resource names, instead of the hard-coded testSpinAppName.
(Again, yes, they all use the same name today, as we've seen in the code -- but they could differ at some point, so it would be preferable to inspect the resources directly.)
Description
This PR addresses the #168 to add more information to
kubectl get spinapps -o wide. Specifically, it adds DEPLOYMENT and SERVICE columns to the output.These columns are configured with
priority: 1, which means they only appear when using the-o wideflag, keeping the default output clean.Changes
kubebuilder:printcolumnmarkers.make manifests).Verification Results
I have verified these changes locally by applying the updated CRDs to a cluster.
Output