troubleshoot icon indicating copy to clipboard operation
troubleshoot copied to clipboard

make Kubernetes object field comparisons easier

Open adamancini opened this issue 3 years ago • 1 comments
trafficstars

Describe the rationale for the suggested feature.

While trying to write a sample spec that looks for a particular image version of a component I expect to have installed, I realized it was tricky to get the API description of a specific deployment.

I would like to be able to easily identify a specific object and get its equivalent kubectl describe or kubectl get -o json|yaml API response and write an analyzer that looks at specific fields.

Today we have jsonCompare which can take a path to a JSON field for comparison, but feeding the data into that analyzer is tricky.

Right now I'm considering using the data from cluster-resources but API descriptions of objects come from kubectl describe <noun> -n <namespace> and all of the deployments for a given namespace are listed in an items[] array. It's not very elegant to have to figure out what integer index belongs to the deployment you want, and it's not very reproducible if the # of deployments changes.

Describe the feature

Add a collector to inspect a specific Kubernetes object, in a specific namespace, and return the complete description of that object in a file so any analyzer can use it.

Describe alternatives you've considered

  • runPod with a kubectl client and jq to handle pulling out the data I need and regex analyzer
  • add additional functionality to deploymentStatus, replicasetStatus etc. analyzers that can do field comparisons on something other than replicas

Additional context

https://github.com/replicatedhq/troubleshoot/issues/712

adamancini avatar Oct 07 '22 19:10 adamancini

Please check #731 also - it's likely to use a similar pattern

xavpaice avatar Oct 13 '22 05:10 xavpaice

https://github.com/replicatedhq/troubleshoot/pull/780 has been merged in, giving us the findResource function, and an example clusterResources analyzer.

The clusterResources analyzer itself is capable of simple yaml comparison, and should be enough to address the needs in this issue.

should more advanced requirements arise, a new analyzer can be written to utilise the findResource function to simplify extracting data about a kubernetes resource from the support bundle.

danj-replicated avatar Jan 09 '23 09:01 danj-replicated

I think to complete the objective of this request entirely, we need to implement a kube API within the analyze portion of Troubleshoot. This is on the roadmap as part of #882 and so I believe we can close this issue now.

xavpaice avatar Jan 10 '23 03:01 xavpaice