apiVersion: troubleshoot.sh/v1beta2
kind: SupportBundle
metadata:
  name: example
spec:
  hostCollectors:
    - hostOS: {}
  collectors:
    - logs:
        selector:
          - app=example
          - component=nginx
        namespace: default
        limits:
          maxAge: 720h # 30*24
          maxLines: 10000
          maxBytes: 5000000
    - logs:
        collectorName: all-logs
        name: all-logs
    - runPod:
        collectorName: "static-hi"
        podSpec:
          containers:
          - name: static-hi
            image: alpine:3
            command: ["echo", "hi static!"]
  analyzers:
    - clusterVersion:
        outcomes:
          - fail:
              when: "< 1.16.0"
              message: The application requires at least Kubernetes 1.16.0 or later
              uri: https://kubernetes.io
          - warn:
              when: "< 1.17.0"
              message: Your cluster meets the minimum version of Kubernetes, but we recommend you update to 1.17.0 or later.
              uri: https://kubernetes.io
          - pass:
              message: Your cluster meets the recommended and required versions of Kubernetes.
    - customResourceDefinition:
        customResourceDefinitionName: rook
        outcomes:
          - fail:
              message: The Rook CRD was not found in the cluster.
              uri: https://kurl.sh/docs/add-ons/rook/some/path/that/does/not/exist/for/the/sake/of/having/a/very/long/url.md
          - pass:
              message: Rook is installed and available.
    - containerRuntime:
        outcomes:
          - fail:
              when: "== docker"
              message: The application does not support docker
          - pass:
              message: A supported container runtime was found
    - storageClass:
        checkName: Required storage classes
        storageClassName: "microk8s-hostpath"
        outcomes:
          - fail:
              message: The microk8s storage class thing was not found
          - pass:
              message: All good on storage classes
    - nodeResources:
        checkName: Must have at least 3 nodes in the cluster
        outcomes:
          - fail:
              when: "count() < 3"
              message: This application requires at least 3 nodes
          - warn:
              when: "count() < 5"
              message: This application recommends at last 5 nodes.
          - pass:
              message: This cluster has enough nodes.
    - nodeResources:
        checkName: Total CPU Cores in the cluster is 4 or greater
        outcomes:
        - fail:
            when: "sum(cpuCapacity) < 4"
            message: The cluster must contain at least 4 cores
        - pass:
            message: There are at least 4 cores in the cluster
    - nodeResources:
        checkName: Each node must have at least 40 GB of ephemeral storage
        outcomes:
        - fail:
            when: "min(ephemeralStorageCapacity) < 40Gi"
            message: Noees in this cluster do not have at least 40 GB of ephemeral storage.
            uri: https://kurl.sh/docs/install-with-kurl/system-requirements
        - warn:
            when: "min(ephemeralStorageCapacity) < 100Gi"
            message: Nodes in this cluster are recommended to have at least 100 GB of ephemeral storage.
            uri: https://kurl.sh/docs/install-with-kurl/system-requirements
        - pass:
            message: The nodes in this cluster have enough ephemeral storage.
    - ingress:
        namespace: default
        ingressName: connect-to-me
        outcomes:
          - fail:
              message: The ingress isn't ingressing
          - pass:
              message: All systems ok on ingress
    - deploymentStatus:
        name: api
        namespace: default
        outcomes:
          - fail:
              when: "< 1"
              message: The API deployment does not have any ready replicas.
          - warn:
              when: "= 1"
              message: The API deployment has only a single ready replica.
          - pass:
              message: There are multiple replicas of the API deployment ready.
    - textAnalyze:
        checkName: Said hi!
        fileName: /static-hi.log
        regex: 'hi static'
        outcomes:
          - fail:
              message: Didn't say hi.
          - pass:
              message: Said hi!
