apiVersion: troubleshoot.sh/v1beta2
kind: SupportBundle
metadata:
  name: support-bundle-gooddata-cn
spec:
  collectors:
    - clusterInfo: {}
    - clusterResources:
        # This is the list of namespaces where applications relevant to GoodData.CN
        # are installed. Update according to your configuration.
        namespaces:
          - gooddata-cn
          - pulsar
          - ingress-nginx
          - cert-manager
    # collect logs from GoodData.CN
    - logs:
        selector:
          - app.kubernetes.io/name=gooddata-cn
      limits:
        maxAge: 1d
        maxLines: 1000
    # collect logs from Apache Pulsar
    - logs:
        selector:
          - app=pulsar
          - cluster=pulsar
      limits:
        maxAge: 1d
        maxLines: 1000
    # collect logs from Cert-manager
    - logs:
        selector:
          - app.kubernetes.io/instance=cert-manager
      limits:
        maxAge: 1d
        maxLines: 1000
    # collect logs from Kubernetes Ingress Controller
    - logs:
        selector:
          - app.kubernetes.io/name=ingress-nginx
      limits:
        maxAge: 1d
        maxLines: 1000
  analyzers:
    - clusterVersion:
        outcomes:
          - fail:
              when: "< 1.21.0"
              message: The application requires Kubernetes 1.22.0 or later
              uri: https://kubernetes.io
          - warn:
              when: ">= 1.25.0"
              message: The Apache Pulsar Helm chart 2.9.x fails to install on Kubernetes 1.25.0 or later
              uri: https://kubernetes.io
          - warn:
              when: "< 1.23.0"
              message: Your cluster meets the minimum version of Kubernetes, but we recommend you update to 1.23.0 or later.
              uri: https://kubernetes.io
          - pass:
              message: Your cluster meets the recommended and required versions of Kubernetes.
    - clusterPodStatuses:
        # This is the list of namespaces where applications relevant to GoodData.CN
        # are installed. Update according to your configuration.
        namespaces:
          - gooddata-cn
          - pulsar
          - ingress-nginx
          - cert-manager
        outcomes:
          - fail:
              when: "!= Healthy"
              message: "Pod {{ .Namespace }}/{{ .Name }} is unhealthy with a status of {{ .Status.Reason }}."
    - nodeResources:
        checkName: Must have at least 3 amd64 nodes in the cluster
        filters:
          cpuArchitecture: amd64
        outcomes:
          - fail:
              when: "count() < 3"
              message: This application requires at least 3 nodes
          - pass:
              message: This cluster has enough nodes.
    - nodeResources:
        checkName: Total CPU Cores on amd64 nodes in the cluster is 12 or greater
        filters:
          cpuArchitecture: amd64
        outcomes:
          - fail:
              when: "sum(cpuCapacity) < 12"
              message: The cluster must contain at least 12 cores on amd64 nodes
          - pass:
              message: There are at least 12 cores on amd64 nodes in the cluster
    - statefulsetStatus: {}
    - deploymentStatus: {}
    - jobStatus: {}
    - replicasetStatus: {}
    - nodeResources:
        checkName: Node status check
        outcomes:
          - fail:
              when: "nodeCondition(Ready) == False"
              message: "Not all nodes are online."
          - fail:
              when: "nodeCondition(Ready) == Unknown"
              message: "Not all nodes are online."
          - pass:
              message: "All nodes are online."
