troubleshoot
troubleshoot copied to clipboard
Add generic kubernetes resource analyzer
This is an attempt at solving a problem where we can't currently directly address resources collected by the cluster-resources collector.
example bundle spec:
apiVersion: troubleshoot.sh/v1beta2
kind: SupportBundle
metadata:
name: collectors
spec:
collectors:
- cluster-resources: {}
analyzers:
- clusterResource:
checkName: ekcko image version
kind: Deployment
namespace: kurl
name: ekc-operator
yamlPath: "spec.template.spec.containers.[0].image"
value: replicated/ekco:v0.22.0
outcomes:
- fail:
when: "false"
message: The ekco deployment is not the latest version
- pass:
when: "true"
message: the ekco deployment is up to date
TODO:
- [x] handle non-namespaced resources
- [x] add tests
https://github.com/replicatedhq/troubleshoot/pull/280/files has some useful things about semver comparisons, though we could have a separate analyzer that uses the same data extraction function to do semver comparison if you wanted.
One limitation of this approach that we should be sure to document is that the name is the actual name of the resource itself, and for things like pods this is more dynamic than we might want. Future additions might include a means to select by label (coping with multiple resources that might match) and/or using wildcards/regex.
You might want to run make schemas to align the new analyser with troubleshoot CRDs. I believe kots-lint depends in these schemas being correct.
Took a look here, and I can come back and give a final review after Evan's comments has been addressed as I agree with what he's suggested also.