troubleshoot
troubleshoot copied to clipboard
make Kubernetes object field comparisons easier
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
runPodwith a kubectl client andjqto handle pulling out the data I need andregexanalyzer- add additional functionality to
deploymentStatus,replicasetStatusetc. analyzers that can do field comparisons on something other thanreplicas
Additional context
https://github.com/replicatedhq/troubleshoot/issues/712
Please check #731 also - it's likely to use a similar pattern
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.
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.