troubleshoot icon indicating copy to clipboard operation
troubleshoot copied to clipboard

Add generic kubernetes resource analyzer

Open danj-replicated opened this issue 3 years ago • 1 comments

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

danj-replicated avatar Oct 13 '22 17:10 danj-replicated

TODO:

  • [x] handle non-namespaced resources
  • [x] add tests

danj-replicated avatar Oct 14 '22 10:10 danj-replicated

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.

xavpaice avatar Oct 27 '22 04:10 xavpaice

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.

xavpaice avatar Oct 27 '22 04:10 xavpaice

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Nov 04 '22 14:11 CLAassistant

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.

banjoh avatar Nov 17 '22 15:11 banjoh

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.

diamonwiggins avatar Nov 22 '22 21:11 diamonwiggins