github.com/argoproj/argo-cd@v1.8.7/docs/operator-manual/health.md (about)

     1  # Resource Health
     2  
     3  ## Overview
     4  Argo CD provides built-in health assessment for several standard Kubernetes types, which is then
     5  surfaced to the overall Application health status as a whole. The following checks are made for
     6  specific types of kubernetes resources:
     7  
     8  ### Deployment, ReplicaSet, StatefulSet DaemonSet
     9  * Observed generation is equal to desired generation.
    10  * Number of **updated** replicas equals the number of desired replicas.
    11  
    12  ### Service
    13  * If service type is of type `LoadBalancer`, the `status.loadBalancer.ingress` list is non-empty,
    14  with at least one value for `hostname` or `IP`.
    15  
    16  ### Ingress
    17  * The `status.loadBalancer.ingress` list is non-empty, with at least one value for `hostname` or `IP`.
    18  
    19  ### PersistentVolumeClaim
    20  * The `status.phase` is `Bound`
    21  
    22  ## Custom Health Checks
    23  
    24  Argo CD supports custom health checks written in [Lua](https://www.lua.org/). This is useful if you:
    25  
    26  * Are affected by known issues where your `Ingress` or `StatefulSet` resources are stuck in `Progressing` state because of bug in your resource controller.
    27  * Have a custom resource for which Argo CD does not have a built-in health check.
    28  
    29  There are two ways to configure a custom health check. The next two sections describe those ways.
    30  
    31  ### Way 1. Define a Custom Health Check in `argocd-cm` ConfigMap
    32  
    33  Custom health checks can be defined in `resource.customizations` field of `argocd-cm`. Following example demonstrates a health check for `cert-manager.io/Certificate`.
    34  
    35  ```yaml
    36  data:
    37    resource.customizations: |
    38      cert-manager.io/Certificate:
    39        health.lua: |
    40          hs = {}
    41          if obj.status ~= nil then
    42            if obj.status.conditions ~= nil then
    43              for i, condition in ipairs(obj.status.conditions) do
    44                if condition.type == "Ready" and condition.status == "False" then
    45                  hs.status = "Degraded"
    46                  hs.message = condition.message
    47                  return hs
    48                end
    49                if condition.type == "Ready" and condition.status == "True" then
    50                  hs.status = "Healthy"
    51                  hs.message = condition.message
    52                  return hs
    53                end
    54              end
    55            end
    56          end
    57          
    58          hs.status = "Progressing"
    59          hs.message = "Waiting for certificate"
    60          return hs
    61  ```
    62  The `obj` is a global variable which contains the resource. The script must return an object with status and optional message field.
    63  
    64  NOTE: as a security measure you don't have access to most of the standard Lua libraries.
    65  
    66  ### Way 2. Contribute a Custom Health Check
    67  
    68  A health check can be bundled into Argo CD. Custom health check scripts are located in the `resource_customizations` directory of [https://github.com/argoproj/argo-cd](https://github.com/argoproj/argo-cd). This must have the following directory structure:
    69  
    70  ```
    71  argo-cd
    72  |-- resource_customizations
    73  |    |-- your.crd.group.io               # CRD group
    74  |    |    |-- MyKind                     # Resource kind
    75  |    |    |    |-- health.lua            # Health check
    76  |    |    |    |-- health_test.yaml      # Test inputs and expected results
    77  |    |    |    +-- testdata              # Directory with test resource YAML definitions
    78  ```
    79  
    80  Each health check must have tests defined in `health_test.yaml` file. The `health_test.yaml` is a YAML file with the following structure:
    81  
    82  ```yaml
    83  tests:
    84  - healthStatus:
    85      status: ExpectedStatus
    86      message: Expected message
    87    inputPath: testdata/test-resource-definition.yaml
    88  ```
    89  
    90  The [PR#1139](https://github.com/argoproj/argo-cd/pull/1139) is an example of Cert Manager CRDs custom health check.