github.com/argoproj/argo-cd/v2@v2.10.5/docs/user-guide/directory.md (about) 1 # Directory 2 3 A directory-type application loads plain manifest files from `.yml`, `.yaml`, and `.json` files. A directory-type 4 application may be created from the UI, CLI, or declaratively. This is the declarative syntax: 5 6 ```yaml 7 apiVersion: argoproj.io/v1alpha1 8 kind: Application 9 metadata: 10 name: guestbook 11 spec: 12 destination: 13 namespace: default 14 server: https://kubernetes.default.svc 15 project: default 16 source: 17 path: guestbook 18 repoURL: https://github.com/argoproj/argocd-example-apps.git 19 targetRevision: HEAD 20 ``` 21 22 It's unnecessary to explicitly add the `spec.source.directory` field except to add additional configuration options. 23 Argo CD will automatically detect that the source repository/path contains plain manifest files. 24 25 ## Enabling Recursive Resource Detection 26 27 By default, directory applications will only include the files from the root of the configured repository/path. 28 29 To enable recursive resource detection, set the `recurse` option. 30 31 ```bash 32 argocd app set guestbook --directory-recurse 33 ``` 34 35 To do the same thing declaratively, use this syntax: 36 37 ```yaml 38 apiVersion: argoproj.io/v1alpha1 39 kind: Application 40 spec: 41 source: 42 directory: 43 recurse: true 44 ``` 45 46 !!! warning 47 Directory-type applications only work for plain manifest files. If Argo CD encounters Kustomize, Helm, or Jsonnet files when directory: is set, it will fail to render the manifests. 48 49 ## Including/Excluding Files 50 51 ### Including Only Certain Files 52 53 To include only certain files/directories in a directory application, set the `include` option. The value is a glob 54 pattern. 55 56 For example, if you want to include only `.yaml` files, you can use this pattern: 57 58 ```shell 59 argocd app set guestbook --directory-include "*.yaml" 60 ``` 61 62 !!! note 63 It is important to quote `*.yaml` so that the shell does not expand the pattern before sending it to Argo CD. 64 65 It is also possible to include multiple patterns. Wrap the patterns with `{}` and separate them with commas. To include 66 `.yml` and `.yaml` files, use this pattern: 67 68 ```shell 69 argocd app set guestbook --directory-include "{*.yml,*.yaml}" 70 ``` 71 72 To include only a certain directory, use a pattern like this: 73 74 ```shell 75 argocd app set guestbook --directory-include "some-directory/*" 76 ``` 77 78 To accomplish the same thing declaratively, use this syntax: 79 80 ```yaml 81 apiVersion: argoproj.io/v1alpha1 82 kind: Application 83 spec: 84 source: 85 directory: 86 include: 'some-directory/*' 87 ``` 88 89 ### Excluding Certain Files 90 91 It is possible to exclude files matching a pattern from directory applications. For example, in a repository containing 92 some manifests and also a non-manifest YAML file, you could exclude the config file like this: 93 94 ```shell 95 argocd app set guestbook --directory-exclude "config.yaml" 96 ``` 97 98 It is possible to exclude more than one pattern. For example, a config file and an irrelevant directory: 99 100 ```shell 101 argocd app set guestbook --directory-exclude "{config.yaml,env-use2/*}" 102 ``` 103 104 If both `include` and `exclude` are specified, then the Application will include all files which match the `include` 105 pattern and do not match the `exclude` pattern. For example, consider this source repository: 106 107 ``` 108 config.json 109 deployment.yaml 110 env-use2/ 111 configmap.yaml 112 env-usw2/ 113 configmap.yaml 114 ``` 115 116 To exclude `config.json` and the `env-usw2` directory, you could use this combination of patterns: 117 118 ```shell 119 argocd app set guestbook --directory-include "*.yaml" --directory-exclude "{config.json,env-usw2/*}" 120 ``` 121 122 This would be the declarative syntax: 123 124 ```yaml 125 apiVersion: argoproj.io/v1alpha1 126 kind: Application 127 spec: 128 source: 129 directory: 130 exclude: '{config.json,env-usw2/*}' 131 include: '*.yaml' 132 ```