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

     1  # High Availability
     2  
     3  Argo CD is largely stateless, all data is persisted as Kubernetes objects, which in turn is stored in Kubernetes' etcd. Redis is only used as a throw-away cache and can be lost. When lost, it will be rebuilt without loss of service.
     4  
     5  A set HA of manifests are provided for users who wish to run Argo CD in a highly available manner. This runs more containers, and run Redis in HA mode.
     6  
     7  [Manifests ⧉](https://github.com/argoproj/argo-cd/tree/master/manifests) 
     8  
     9  !!! note
    10      The HA installation will require at least three different nodes due to pod anti-affinity roles in the specs.
    11  
    12  ## Scaling Up
    13  
    14  ### argocd-repo-server
    15  
    16  **settings:**
    17  
    18  The `argocd-repo-server` is responsible for cloning Git repository, keeping it up to date and generating manifests using the appropriate tool.
    19  
    20  * `argocd-repo-server` fork/exec config management tool to generate manifests. The fork can fail due to lack of memory and limit on the number of OS threads.
    21  The `--parallelismlimit` flag controls how many manifests generations are running concurrently and allows avoiding OOM kills.
    22  
    23  * the `argocd-repo-server` ensures that repository is in the clean state during the manifest generation using config management tools such as Kustomize, Helm
    24  or custom plugin. As a result Git repositories with multiple applications might be affect repository server performance.
    25  Read [Monorepo Scaling Considerations](#monorepo-scaling-considerations) for more information.
    26  
    27  * `argocd-repo-server` clones repository into `/tmp` ( of path specified in `TMPDIR` env variable ). Pod might run out of disk space if have too many repository
    28  or repositories has a lot of files. To avoid this problem mount persistent volume.
    29  
    30  * `argocd-repo-server` `git ls-remote` to resolve ambiguous revision such as `HEAD`, branch or tag name. This operation is happening pretty frequently
    31  and might fail. To avoid failed syncs use `ARGOCD_GIT_ATTEMPTS_COUNT` environment variable to retry failed requests.
    32  
    33  * `argocd-repo-server` Every 3m (by default) Argo CD checks for changes to the app manifests. Argo CD assumes by default that manifests only change when the repo changes, so it caches generated manifests (for 24h by default). With Kustomize remote bases, or Helm patch releases, the manifests can change even though the repo has not changed. By reducing the cache time, you can get the changes without waiting for 24h. Use `--repo-cache-expiration duration`, and we'd suggest in low volume environments you try '1h'. Bear in mind this will negate the benefit of caching if set too low. 
    34  
    35  **metrics:**
    36  
    37  * `argocd_git_request_total` - Number of git requests. The metric provides two tags: `repo` - Git repo URL; `request_type` - `ls-remote` or `fetch`.
    38  
    39  * `ARGOCD_ENABLE_GRPC_TIME_HISTOGRAM` (v1.8+) - environment variable that enables collecting RPC performance metrics. Enable it if you need to troubleshoot performance issue. Note: metric is expensive to both query and store!
    40  
    41  ### argocd-application-controller
    42  
    43  **settings:**
    44  
    45  The `argocd-application-controller` uses `argocd-repo-server` to get generated manifests and Kubernetes API server to get actual cluster state.
    46  
    47  * each controller replica uses two separate queues to process application reconciliation (milliseconds) and app syncing (seconds). Number of queue processors for each queue is controlled by
    48  `--status-processors` (20 by default) and `--operation-processors` (10 by default) flags. Increase number of processors if your Argo CD instance manages too many applications.
    49  For 1000 application we use 50 for `--status-processors` and 25 for `--operation-processors`
    50  
    51  * The manifest generation typically takes the most time during reconciliation. The duration of manifest generation is limited to make sure controller refresh queue does not overflow.
    52  The app reconciliation fails with `Context deadline exceeded` error if manifest generating taking too much time. As workaround increase value of `--repo-server-timeout-seconds` and
    53  consider scaling up `argocd-repo-server` deployment.
    54  
    55  * The controller uses `kubectl` fork/exec to push changes into the cluster and to convert resource from preferred version into user specified version
    56  (e.g. Deployment `apps/v1` into `extensions/v1beta1`). Same as config management tool `kubectl` fork/exec might cause pod OOM kill. Use `--kubectl-parallelism-limit` flag to limit
    57  number of allowed concurrent kubectl fork/execs.
    58  
    59  * The controller uses Kubernetes watch APIs to maintain lightweight Kubernetes cluster cache. This allows to avoid querying Kubernetes during app reconciliation and significantly improve
    60  performance. For performance reasons controller monitors and caches only preferred the version of a resource. During reconciliation, the controller might have to convert cached resource from
    61  preferred version into a version of the resource stored in Git. If `kubectl convert` fails because conversion is not supported than controller fallback to Kubernetes API query which slows down
    62  reconciliation. In this case advice user-preferred resource version in Git.
    63  
    64  * The controller polls Git every 3m by default. You can increase this duration using `--app-resync seconds` to reduce polling.
    65  
    66  * If the controller is managing too many clusters and uses too much memory then you can shard clusters across multiple
    67  controller replicas. To enable sharding increase the number of replicas in `argocd-application-controller` `StatefulSet`
    68  and repeat number of replicas in `ARGOCD_CONTROLLER_REPLICAS` environment variable. The strategic merge patch below
    69  demonstrates changes required to configure two controller replicas.
    70  
    71  ```yaml
    72  apiVersion: apps/v1
    73  kind: StatefulSet
    74  metadata:
    75    name: argocd-application-controller
    76  spec:
    77    replicas: 2
    78    template:
    79      spec:
    80        containers:
    81        - name: argocd-application-controller
    82          env:
    83          - name: ARGOCD_CONTROLLER_REPLICAS
    84            value: "2"
    85  ```
    86  
    87  * `ARGOCD_ENABLE_GRPC_TIME_HISTOGRAM`  (v1.8+)- environment variable that enables collecting RPC performance metrics. Enable it if you need to troubleshoot performance issue. Note: metric is expensive to both query and store!
    88  
    89  **metrics**
    90  
    91  * `argocd_app_reconcile` - reports application reconciliation duration. Can be used to build reconciliation duration heat map to get high-level reconciliation performance picture.
    92  * `argocd_app_k8s_request_total` - number of k8s requests per application. The number of fallback Kubernetes API queries - useful to identify which application has a resource with
    93  non-preferred version and causes performance issues.
    94  
    95  ### argocd-server
    96  
    97  The `argocd-server` is stateless and probably least likely to cause issues. You might consider increasing number of replicas to 3 or more to ensure there is no downtime during upgrades.
    98  
    99  **settings:**
   100  
   101  * The `ARGOCD_GRPC_MAX_SIZE_MB` environment variable allows specifying the max size of the server response message in megabytes.
   102  The default value is 200. You might need to increase for an Argo CD instance that manages 3000+ applications.    
   103  
   104  ### argocd-dex-server, argocd-redis
   105  
   106  The `argocd-dex-server` uses an in-memory database, and two or more instances would have inconsistent data. `argocd-redis` is pre-configured with the understanding of only three total redis servers/sentinels.
   107  
   108  ## Monorepo Scaling Considerations
   109  
   110  Argo CD repo server maintains one repository clone locally and use it for application manifest generation. If the manifest generation requires to change a file in the local repository clone then only one concurrent manifest generation per server instance is allowed. This limitation might significantly slowdown Argo CD if you have a mono repository with multiple applications (50+).
   111  
   112  ### Enable Concurrent Processing
   113  
   114  Argo CD determines if manifest generation might change local files in the local repository clone based on config management tool and application settings.
   115  If the manifest generation has no side effects then requests are processed in parallel without the performance penalty. Following are known cases that might cause slowness and workarounds:
   116  
   117    * **Multiple Helm based applications pointing to the same directory in one Git repository:** ensure that your Helm chart don't have don't have conditional
   118  [dependencies](https://helm.sh/docs/chart_best_practices/dependencies/#conditions-and-tags) and create `.argocd-allow-concurrency` file in chart directory.
   119  
   120    * **Multiple Custom plugin based applications:** avoid creating temporal files during manifest generation and and create `.argocd-allow-concurrency` file in app directory.
   121  
   122    * **Multiple Kustomize or Ksonnet applications in same repository with [parameter overrides](../user-guide/parameters.md):** sorry, no workaround for now.
   123  
   124  
   125  ### Webhook and Manifest Paths Annotation
   126  
   127  Argo CD aggressively caches generated manifests and uses repository commit SHA as a cache key. A new commit to the Git repository invalidates cache for all applications configured in the repository
   128  that again negatively affect mono repositories with multiple applications. You might use [webhooks ⧉](https://github.com/argoproj/argo-cd/tree/master/docs/operator-manual/webhook) and `argocd.argoproj.io/manifest-generate-paths` Application
   129  CRD annotation to solve this problem and improve performance.
   130  
   131  The `argocd.argoproj.io/manifest-generate-paths` contains a semicolon-separated list of paths within the Git repository that are used during manifest generation. The webhook compares paths specified in the annotation
   132  with the changed files specified in the webhook payload. If non of the changed files are located in the paths then webhook don't trigger application reconciliation and re-uses previously generated manifests cache for a new commit.
   133  
   134  Installations that use a different repo for each app are **not** subject to this behavior and will likely get no benefit from using these annotations.
   135  
   136  !!! note
   137      Installations with a large number of apps should also set the `--app-resync` flag in the `argocd-application-controller` process to a larger value to reduce automatic refreshes based on git polling. The exact value is a trade-off between reduced work and app sync in case of a missed webhook event. For most cases `1800` (30m) or `3600` (1h) is a good trade-off.
   138  
   139  
   140  !!! note
   141      Application manifest paths annotation support depends on the git provider used for the Application. It is currently only supported for GitHub, GitLab, and Gogs based repos
   142  
   143  * **Relative path** The annotation might contains relative path. In this case the path is considered relative to the path specified in the application source:
   144  
   145  ```yaml
   146  apiVersion: argoproj.io/v1alpha1
   147  kind: Application
   148  metadata:
   149    name: guestbook
   150    namespace: argocd
   151    annotations:
   152      # resolves to the 'guestbook' directory
   153      argocd.argoproj.io/manifest-generate-paths: .
   154  spec:
   155    source:
   156      repoURL: https://github.com/argoproj/argocd-example-apps.git
   157      targetRevision: HEAD
   158      path: guestbook
   159  # ...
   160  ```
   161  * **Absolute path** The annotation value might be an absolute path started from '/'. In this case path is considered as an absolute path within the Git repository:
   162  
   163  ```yaml
   164  apiVersion: argoproj.io/v1alpha1
   165  kind: Application
   166  metadata:
   167    name: guestbook
   168    annotations:
   169      argocd.argoproj.io/manifest-generate-paths: /guestbook
   170  spec:
   171    source:
   172      repoURL: https://github.com/argoproj/argocd-example-apps.git
   173      targetRevision: HEAD
   174      path: guestbook
   175  # ...
   176  ```
   177  
   178  * **Multiple paths** It is possible to put multiple paths into the annotation. Paths must be separated with a semicolon (`;`):
   179  
   180  ```yaml
   181  apiVersion: argoproj.io/v1alpha1
   182  kind: Application
   183  metadata:
   184    name: guestbook
   185    annotations:
   186      # resolves to 'my-application' and 'shared'
   187      argocd.argoproj.io/manifest-generate-paths: .;../shared
   188  spec:
   189    source:
   190      repoURL: https://github.com/argoproj/argocd-example-apps.git
   191      targetRevision: HEAD
   192      path: my-application
   193  # ...
   194  ```