github.com/argoproj/argo-cd/v2@v2.10.9/docs/operator-manual/declarative-setup.md (about) 1 # Declarative Setup 2 3 Argo CD applications, projects and settings can be defined declaratively using Kubernetes manifests. These can be updated using `kubectl apply`, without needing to touch the `argocd` command-line tool. 4 5 ## Quick Reference 6 7 All resources, including `Application` and `AppProject` specs, have to be installed in the Argo CD namespace (by default `argocd`). 8 9 ### Atomic configuration 10 11 | Sample File | Resource Name | Kind | Description | 12 |-----------------------------------------------------------------------|------------------------------------------------------------------------------------|-----------|--------------------------------------------------------------------------------------| 13 | [`argocd-cm.yaml`](argocd-cm-yaml.md) | argocd-cm | ConfigMap | General Argo CD configuration | 14 | [`argocd-repositories.yaml`](argocd-repositories-yaml.md) | my-private-repo / istio-helm-repo / private-helm-repo / private-repo | Secrets | Sample repository connection details | 15 | [`argocd-repo-creds.yaml`](argocd-repo-creds-yaml.md) | argoproj-https-creds / argoproj-ssh-creds / github-creds / github-enterprise-creds | Secrets | Sample repository credential templates | 16 | [`argocd-cmd-params-cm.yaml`](argocd-cmd-params-cm-yaml.md) | argocd-cmd-params-cm | ConfigMap | Argo CD env variables configuration | 17 | [`argocd-secret.yaml`](argocd-secret-yaml.md) | argocd-secret | Secret | User Passwords, Certificates (deprecated), Signing Key, Dex secrets, Webhook secrets | 18 | [`argocd-rbac-cm.yaml`](argocd-rbac-cm-yaml.md) | argocd-rbac-cm | ConfigMap | RBAC Configuration | 19 | [`argocd-tls-certs-cm.yaml`](argocd-tls-certs-cm-yaml.md) | argocd-tls-certs-cm | ConfigMap | Custom TLS certificates for connecting Git repositories via HTTPS (v1.2 and later) | 20 | [`argocd-ssh-known-hosts-cm.yaml`](argocd-ssh-known-hosts-cm-yaml.md) | argocd-ssh-known-hosts-cm | ConfigMap | SSH known hosts data for connecting Git repositories via SSH (v1.2 and later) | 21 22 For each specific kind of ConfigMap and Secret resource, there is only a single supported resource name (as listed in the above table) - if you need to merge things you need to do it before creating them. 23 24 !!!warning "A note about ConfigMap resources" 25 Be sure to annotate your ConfigMap resources using the label `app.kubernetes.io/part-of: argocd`, otherwise Argo CD will not be able to use them. 26 27 ### Multiple configuration objects 28 29 | Sample File | Kind | Description | 30 |------------------------------------------------------------------|-------------|--------------------------| 31 | [`application.yaml`](../user-guide/application-specification.md) | Application | Example application spec | 32 | [`project.yaml`](./project-specification.md) | AppProject | Example project spec | 33 | - | Secret | Repository credentials | 34 35 For `Application` and `AppProject` resources, the name of the resource equals the name of the application or project within Argo CD. This also means that application and project names are unique within a given Argo CD installation - you cannot have the same application name for two different applications. 36 37 ## Applications 38 39 The Application CRD is the Kubernetes resource object representing a deployed application instance 40 in an environment. It is defined by two key pieces of information: 41 42 * `source` reference to the desired state in Git (repository, revision, path, environment) 43 * `destination` reference to the target cluster and namespace. For the cluster one of server or name can be used, but not both (which will result in an error). Under the hood when the server is missing, it is calculated based on the name and used for any operations. 44 45 A minimal Application spec is as follows: 46 47 ```yaml 48 apiVersion: argoproj.io/v1alpha1 49 kind: Application 50 metadata: 51 name: guestbook 52 namespace: argocd 53 spec: 54 project: default 55 source: 56 repoURL: https://github.com/argoproj/argocd-example-apps.git 57 targetRevision: HEAD 58 path: guestbook 59 destination: 60 server: https://kubernetes.default.svc 61 namespace: guestbook 62 ``` 63 64 See [application.yaml](application.yaml) for additional fields. As long as you have completed the first step of [Getting Started](../getting_started.md#1-install-argo-cd), you can apply this with `kubectl apply -n argocd -f application.yaml` and Argo CD will start deploying the guestbook application. 65 66 !!! note 67 The namespace must match the namespace of your Argo CD instance - typically this is `argocd`. 68 69 !!! note 70 When creating an application from a Helm repository, the `chart` attribute must be specified instead of the `path` attribute within `spec.source`. 71 72 ```yaml 73 spec: 74 source: 75 repoURL: https://argoproj.github.io/argo-helm 76 chart: argo 77 ``` 78 79 !!! warning 80 Without the `resources-finalizer.argocd.argoproj.io` finalizer, deleting an application will not delete the resources it manages. To perform a cascading delete, you must add the finalizer. See [App Deletion](../user-guide/app_deletion.md#about-the-deletion-finalizer). 81 82 ```yaml 83 metadata: 84 finalizers: 85 - resources-finalizer.argocd.argoproj.io 86 ``` 87 88 ### App of Apps 89 90 You can create an app that creates other apps, which in turn can create other apps. 91 This allows you to declaratively manage a group of apps that can be deployed and configured in concert. 92 93 See [cluster bootstrapping](cluster-bootstrapping.md). 94 95 ## Projects 96 97 The AppProject CRD is the Kubernetes resource object representing a logical grouping of applications. 98 It is defined by the following key pieces of information: 99 100 * `sourceRepos` reference to the repositories that applications within the project can pull manifests from. 101 * `destinations` reference to clusters and namespaces that applications within the project can deploy into. 102 * `roles` list of entities with definitions of their access to resources within the project. 103 104 !!!warning "Projects which can deploy to the Argo CD namespace grant admin access" 105 If a Project's `destinations` configuration allows deploying to the namespace in which Argo CD is installed, then 106 Applications under that project have admin-level access. [RBAC access](https://argo-cd.readthedocs.io/en/stable/operator-manual/rbac/) 107 to admin-level Projects should be carefully restricted, and push access to allowed `sourceRepos` should be limited 108 to only admins. 109 110 An example spec is as follows: 111 112 ```yaml 113 apiVersion: argoproj.io/v1alpha1 114 kind: AppProject 115 metadata: 116 name: my-project 117 namespace: argocd 118 # Finalizer that ensures that project is not deleted until it is not referenced by any application 119 finalizers: 120 - resources-finalizer.argocd.argoproj.io 121 spec: 122 description: Example Project 123 # Allow manifests to deploy from any Git repos 124 sourceRepos: 125 - '*' 126 # Only permit applications to deploy to the guestbook namespace in the same cluster 127 destinations: 128 - namespace: guestbook 129 server: https://kubernetes.default.svc 130 # Deny all cluster-scoped resources from being created, except for Namespace 131 clusterResourceWhitelist: 132 - group: '' 133 kind: Namespace 134 # Allow all namespaced-scoped resources to be created, except for ResourceQuota, LimitRange, NetworkPolicy 135 namespaceResourceBlacklist: 136 - group: '' 137 kind: ResourceQuota 138 - group: '' 139 kind: LimitRange 140 - group: '' 141 kind: NetworkPolicy 142 # Deny all namespaced-scoped resources from being created, except for Deployment and StatefulSet 143 namespaceResourceWhitelist: 144 - group: 'apps' 145 kind: Deployment 146 - group: 'apps' 147 kind: StatefulSet 148 roles: 149 # A role which provides read-only access to all applications in the project 150 - name: read-only 151 description: Read-only privileges to my-project 152 policies: 153 - p, proj:my-project:read-only, applications, get, my-project/*, allow 154 groups: 155 - my-oidc-group 156 # A role which provides sync privileges to only the guestbook-dev application, e.g. to provide 157 # sync privileges to a CI system 158 - name: ci-role 159 description: Sync privileges for guestbook-dev 160 policies: 161 - p, proj:my-project:ci-role, applications, sync, my-project/guestbook-dev, allow 162 # NOTE: JWT tokens can only be generated by the API server and the token is not persisted 163 # anywhere by Argo CD. It can be prematurely revoked by removing the entry from this list. 164 jwtTokens: 165 - iat: 1535390316 166 ``` 167 168 ## Repositories 169 170 !!!note 171 Some Git hosters - notably GitLab and possibly on-premise GitLab instances as well - require you to 172 specify the `.git` suffix in the repository URL, otherwise they will send a HTTP 301 redirect to the 173 repository URL suffixed with `.git`. Argo CD will **not** follow these redirects, so you have to 174 adjust your repository URL to be suffixed with `.git`. 175 176 Repository details are stored in secrets. To configure a repo, create a secret which contains repository details. 177 Consider using [bitnami-labs/sealed-secrets](https://github.com/bitnami-labs/sealed-secrets) to store an encrypted secret definition as a Kubernetes manifest. 178 Each repository must have a `url` field and, depending on whether you connect using HTTPS, SSH, or GitHub App, `username` and `password` (for HTTPS), `sshPrivateKey` (for SSH), or `githubAppPrivateKey` (for GitHub App). 179 180 !!!warning 181 When using [bitnami-labs/sealed-secrets](https://github.com/bitnami-labs/sealed-secrets) the labels will be removed and have to be readded as described here: https://github.com/bitnami-labs/sealed-secrets#sealedsecrets-as-templates-for-secrets 182 183 Example for HTTPS: 184 185 ```yaml 186 apiVersion: v1 187 kind: Secret 188 metadata: 189 name: private-repo 190 namespace: argocd 191 labels: 192 argocd.argoproj.io/secret-type: repository 193 stringData: 194 type: git 195 url: https://github.com/argoproj/private-repo 196 password: my-password 197 username: my-username 198 ``` 199 200 Example for SSH: 201 202 ```yaml 203 apiVersion: v1 204 kind: Secret 205 metadata: 206 name: private-repo 207 namespace: argocd 208 labels: 209 argocd.argoproj.io/secret-type: repository 210 stringData: 211 type: git 212 url: git@github.com:argoproj/my-private-repository.git 213 sshPrivateKey: | 214 -----BEGIN OPENSSH PRIVATE KEY----- 215 ... 216 -----END OPENSSH PRIVATE KEY----- 217 ``` 218 219 Example for GitHub App: 220 221 ```yaml 222 apiVersion: v1 223 kind: Secret 224 metadata: 225 name: github-repo 226 namespace: argocd 227 labels: 228 argocd.argoproj.io/secret-type: repository 229 stringData: 230 type: git 231 url: https://github.com/argoproj/my-private-repository 232 githubAppID: 1 233 githubAppInstallationID: 2 234 githubAppPrivateKey: | 235 -----BEGIN OPENSSH PRIVATE KEY----- 236 ... 237 -----END OPENSSH PRIVATE KEY----- 238 --- 239 apiVersion: v1 240 kind: Secret 241 metadata: 242 name: github-enterprise-repo 243 namespace: argocd 244 labels: 245 argocd.argoproj.io/secret-type: repository 246 stringData: 247 type: git 248 url: https://ghe.example.com/argoproj/my-private-repository 249 githubAppID: 1 250 githubAppInstallationID: 2 251 githubAppEnterpriseBaseUrl: https://ghe.example.com/api/v3 252 githubAppPrivateKey: | 253 -----BEGIN OPENSSH PRIVATE KEY----- 254 ... 255 -----END OPENSSH PRIVATE KEY----- 256 ``` 257 258 Example for Google Cloud Source repositories: 259 260 ```yaml 261 kind: Secret 262 metadata: 263 name: github-repo 264 namespace: argocd 265 labels: 266 argocd.argoproj.io/secret-type: repository 267 stringData: 268 type: git 269 url: https://source.developers.google.com/p/my-google-project/r/my-repo 270 gcpServiceAccountKey: | 271 { 272 "type": "service_account", 273 "project_id": "my-google-project", 274 "private_key_id": "REDACTED", 275 "private_key": "-----BEGIN PRIVATE KEY-----\nREDACTED\n-----END PRIVATE KEY-----\n", 276 "client_email": "argocd-service-account@my-google-project.iam.gserviceaccount.com", 277 "client_id": "REDACTED", 278 "auth_uri": "https://accounts.google.com/o/oauth2/auth", 279 "token_uri": "https://oauth2.googleapis.com/token", 280 "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", 281 "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/argocd-service-account%40my-google-project.iam.gserviceaccount.com" 282 } 283 ``` 284 285 !!! tip 286 The Kubernetes documentation has [instructions for creating a secret containing a private key](https://kubernetes.io/docs/concepts/configuration/secret/#use-case-pod-with-ssh-keys). 287 288 ### Repository Credentials 289 290 If you want to use the same credentials for multiple repositories, you can configure credential templates. Credential templates can carry the same credentials information as repositories. 291 292 ```yaml 293 apiVersion: v1 294 kind: Secret 295 metadata: 296 name: first-repo 297 namespace: argocd 298 labels: 299 argocd.argoproj.io/secret-type: repository 300 stringData: 301 type: git 302 url: https://github.com/argoproj/private-repo 303 --- 304 apiVersion: v1 305 kind: Secret 306 metadata: 307 name: second-repo 308 namespace: argocd 309 labels: 310 argocd.argoproj.io/secret-type: repository 311 stringData: 312 type: git 313 url: https://github.com/argoproj/other-private-repo 314 --- 315 apiVersion: v1 316 kind: Secret 317 metadata: 318 name: private-repo-creds 319 namespace: argocd 320 labels: 321 argocd.argoproj.io/secret-type: repo-creds 322 stringData: 323 type: git 324 url: https://github.com/argoproj 325 password: my-password 326 username: my-username 327 ``` 328 329 In the above example, every repository accessed via HTTPS whose URL is prefixed with `https://github.com/argoproj` would use a username stored in the key `username` and a password stored in the key `password` of the secret `private-repo-creds` for connecting to Git. 330 331 In order for Argo CD to use a credential template for any given repository, the following conditions must be met: 332 333 * The repository must either not be configured at all, or if configured, must not contain any credential information (i.e. contain none of `sshPrivateKey`, `username`, `password` ) 334 * The URL configured for a credential template (e.g. `https://github.com/argoproj`) must match as prefix for the repository URL (e.g. `https://github.com/argoproj/argocd-example-apps`). 335 336 !!! note 337 Matching credential template URL prefixes is done on a _best match_ effort, so the longest (best) match will take precedence. The order of definition is not important, as opposed to pre v1.4 configuration. 338 339 The following keys are valid to refer to credential secrets: 340 341 #### SSH repositories 342 343 * `sshPrivateKey` refers to the SSH private key for accessing the repositories 344 345 #### HTTPS repositories 346 347 * `username` and `password` refer to the username and/or password for accessing the repositories 348 * `tlsClientCertData` and `tlsClientCertKey` refer to secrets where a TLS client certificate (`tlsClientCertData`) and the corresponding private key `tlsClientCertKey` are stored for accessing the repositories 349 350 #### GitHub App repositories 351 352 * `githubAppPrivateKey` refers to the GitHub App private key for accessing the repositories 353 * `githubAppID` refers to the GitHub Application ID for the application you created. 354 * `githubAppInstallationID` refers to the Installation ID of the GitHub app you created and installed. 355 * `githubAppEnterpriseBaseUrl` refers to the base api URL for GitHub Enterprise (e.g. `https://ghe.example.com/api/v3`) 356 * `tlsClientCertData` and `tlsClientCertKey` refer to secrets where a TLS client certificate (`tlsClientCertData`) and the corresponding private key `tlsClientCertKey` are stored for accessing GitHub Enterprise if custom certificates are used. 357 358 ### Repositories using self-signed TLS certificates (or are signed by custom CA) 359 360 You can manage the TLS certificates used to verify the authenticity of your repository servers in a ConfigMap object named `argocd-tls-certs-cm`. The data section should contain a map, with the repository server's hostname part (not the complete URL) as key, and the certificate(s) in PEM format as data. So, if you connect to a repository with the URL `https://server.example.com/repos/my-repo`, you should use `server.example.com` as key. The certificate data should be either the server's certificate (in case of self-signed certificate) or the certificate of the CA that was used to sign the server's certificate. You can configure multiple certificates for each server, e.g. if you are having a certificate roll-over planned. 361 362 If there are no dedicated certificates configured for a repository server, the system's default trust store is used for validating the server's repository. This should be good enough for most (if not all) public Git repository services such as GitLab, GitHub and Bitbucket as well as most privately hosted sites which use certificates from well-known CAs, including Let's Encrypt certificates. 363 364 An example ConfigMap object: 365 366 ```yaml 367 apiVersion: v1 368 kind: ConfigMap 369 metadata: 370 name: argocd-tls-certs-cm 371 namespace: argocd 372 labels: 373 app.kubernetes.io/name: argocd-cm 374 app.kubernetes.io/part-of: argocd 375 data: 376 server.example.com: | 377 -----BEGIN CERTIFICATE----- 378 MIIF1zCCA7+gAwIBAgIUQdTcSHY2Sxd3Tq/v1eIEZPCNbOowDQYJKoZIhvcNAQEL 379 BQAwezELMAkGA1UEBhMCREUxFTATBgNVBAgMDExvd2VyIFNheG9ueTEQMA4GA1UE 380 BwwHSGFub3ZlcjEVMBMGA1UECgwM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HQ4EFgQUjXH6PHi92y4C4hQpey86 397 r6+x1ewwHwYDVR0jBBgwFoAUjXH6PHi92y4C4hQpey86r6+x1ewwDwYDVR0TAQH/ 398 BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAFE4SdKsX9UsLy+Z0xuHSxhTd0jfn 399 Iih5mtzb8CDNO5oTw4z0aMeAvpsUvjJ/XjgxnkiRACXh7K9hsG2r+ageRWGevyvx 400 CaRXFbherV1kTnZw4Y9/pgZTYVWs9jlqFOppz5sStkfjsDQ5lmPJGDii/StENAz2 401 XmtiPOgfG9Upb0GAJBCuKnrU9bIcT4L20gd2F4Y14ccyjlf8UiUi192IX6yM9OjT 402 +TuXwZgqnTOq6piVgr+FTSa24qSvaXb5z/mJDLlk23npecTouLg83TNSn3R6fYQr 403 d/Y9eXuUJ8U7/qTh2Ulz071AO9KzPOmleYPTx4Xty4xAtWi1QE5NHW9/Ajlv5OtO 404 OnMNWIs7ssDJBsB7VFC8hcwf79jz7kC0xmQqDfw51Xhhk04kla+v+HZcFW2AO9so 405 6ZdVHHQnIbJa7yQJKZ+hK49IOoBR6JgdB5kymoplLLiuqZSYTcwSBZ72FYTm3iAr 406 jzvt1hxpxVDmXvRnkhRrIRhK4QgJL0jRmirBjDY+PYYd7bdRIjN7WNZLFsgplnS8 407 9w6CwG32pRlm0c8kkiQ7FXA6BYCqOsDI8f1VGQv331OpR2Ck+FTv+L7DAmg6l37W 408 +LB9LGh4OAp68ImTjqf6ioGKG0RBSznwME+r4nXtT1S/qLR6ASWUS4ViWRhbRlNK 409 XWyb96wrUlv+E8I= 410 -----END CERTIFICATE----- 411 412 ``` 413 414 !!! note 415 The `argocd-tls-certs-cm` ConfigMap will be mounted as a volume at the mount path `/app/config/tls` in the pods of `argocd-server` and `argocd-repo-server`. It will create files for each data key in the mount path directory, so above example would leave the file `/app/config/tls/server.example.com`, which contains the certificate data. It might take a while for changes in the ConfigMap to be reflected in your pods, depending on your Kubernetes configuration. 416 417 ### SSH known host public keys 418 419 If you are configuring repositories to use SSH, Argo CD will need to know their SSH public keys. In order for Argo CD to connect via SSH the public key(s) for each repository server must be pre-configured in Argo CD (unlike TLS configuration), otherwise the connections to the repository will fail. 420 421 You can manage the SSH known hosts data in the `argocd-ssh-known-hosts-cm` ConfigMap. This ConfigMap contains a single entry, `ssh_known_hosts`, with the public keys of the SSH servers as its value. The value can be filled in from any existing `ssh_known_hosts` file, or from the output of the `ssh-keyscan` utility (which is part of OpenSSH's client package). The basic format is `<server_name> <keytype> <base64-encoded_key>`, one entry per line. 422 423 Here is an example of running `ssh-keyscan`: 424 ```bash 425 $ for host in bitbucket.org github.com gitlab.com ssh.dev.azure.com vs-ssh.visualstudio.com ; do ssh-keyscan $host 2> /dev/null ; done 426 bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDQeJzhupRu0u0cdegZIa8e86EG2qOCsIsD1Xw0xSeiPDlCr7kq97NLmMbpKTX6Esc30NuoqEEHCuc7yWtwp8dI76EEEB1VqY9QJq6vk+aySyboD5QF61I/1WeTwu+deCbgKMGbUijeXhtfbxSxm6JwGrXrhBdofTsbKRUsrN1WoNgUa8uqN1Vx6WAJw1JHPhglEGGHea6QICwJOAr/6mrui/oB7pkaWKHj3z7d1IC4KWLtY47elvjbaTlkN04Kc/5LFEirorGYVbt15kAUlqGM65pk6ZBxtaO3+30LVlORZkxOh+LKL/BvbZ/iRNhItLqNyieoQj/uh/7Iv4uyH/cV/0b4WDSd3DptigWq84lJubb9t/DnZlrJazxyDCulTmKdOR7vs9gMTo+uoIrPSb8ScTtvw65+odKAlBj59dhnVp9zd7QUojOpXlL62Aw56U4oO+FALuevvMjiWeavKhJqlR7i5n9srYcrNV7ttmDw7kf/97P5zauIhxcjX+xHv4M= 427 github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl 428 github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB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8XIq/U0tCNyokEi/ueaBMCvbcTHhO7FcwzY92WK4Yt0aGROY5qX2UKSeOvuP4D6TPqKF1onrSzH9bx9XUf2lEdWT/ia1NEKjunUqu1xOB/StKDHMoX4/OKyIzuS0q/T1zOATthvasJFoPrAjkohTyaDUz2LN5JoH839hViyEG82yB+MjcFV5MU3N1l1QL3cVUCh93xSaua1N85qivl+siMkPGbO5xR/En4iEY6K2XPASUEMaieWVNTRCtJ4S8H+9 433 ssh.dev.azure.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7Hr1oTWqNqOlzGJOfGJ4NakVyIzf1rXYd4d7wo6jBlkLvCA4odBlL0mDUyZ0/QUfTTqeu+tm22gOsv+VrVTMk6vwRU75gY/y9ut5Mb3bR5BV58dKXyq9A9UeB5Cakehn5Zgm6x1mKoVyf+FFn26iYqXJRgzIZZcZ5V6hrE0Qg39kZm4az48o0AUbf6Sp4SLdvnuMa2sVNwHBboS7EJkm57XQPVU3/QpyNLHbWDdzwtrlS+ez30S3AdYhLKEOxAG8weOnyrtLJAUen9mTkol8oII1edf7mWWbWVf0nBmly21+nZcmCTISQBtdcyPaEno7fFQMDD26/s0lfKob4Kw8H 434 vs-ssh.visualstudio.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7Hr1oTWqNqOlzGJOfGJ4NakVyIzf1rXYd4d7wo6jBlkLvCA4odBlL0mDUyZ0/QUfTTqeu+tm22gOsv+VrVTMk6vwRU75gY/y9ut5Mb3bR5BV58dKXyq9A9UeB5Cakehn5Zgm6x1mKoVyf+FFn26iYqXJRgzIZZcZ5V6hrE0Qg39kZm4az48o0AUbf6Sp4SLdvnuMa2sVNwHBboS7EJkm57XQPVU3/QpyNLHbWDdzwtrlS+ez30S3AdYhLKEOxAG8weOnyrtLJAUen9mTkol8oII1edf7mWWbWVf0nBmly21+nZcmCTISQBtdcyPaEno7fFQMDD26/s0lfKob4Kw8H 435 ``` 436 437 Here is an example `ConfigMap` object using the output from `ssh-keyscan` above: 438 439 ```yaml 440 apiVersion: v1 441 kind: ConfigMap 442 metadata: 443 labels: 444 app.kubernetes.io/name: argocd-ssh-known-hosts-cm 445 app.kubernetes.io/part-of: argocd 446 name: argocd-ssh-known-hosts-cm 447 data: 448 ssh_known_hosts: | 449 # This file was automatically generated by hack/update-ssh-known-hosts.sh. DO NOT EDIT 450 [ssh.github.com]:443 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg= 451 [ssh.github.com]:443 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl 452 [ssh.github.com]:443 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk= 453 bitbucket.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPIQmuzMBuKdWeF4+a2sjSSpBK0iqitSQ+5BM9KhpexuGt20JpTVM7u5BDZngncgrqDMbWdxMWWOGtZ9UgbqgZE= 454 bitbucket.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIazEu89wgQZ4bqs3d63QSMzYVa0MuJ2e2gKTKqu+UUO 455 bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDQeJzhupRu0u0cdegZIa8e86EG2qOCsIsD1Xw0xSeiPDlCr7kq97NLmMbpKTX6Esc30NuoqEEHCuc7yWtwp8dI76EEEB1VqY9QJq6vk+aySyboD5QF61I/1WeTwu+deCbgKMGbUijeXhtfbxSxm6JwGrXrhBdofTsbKRUsrN1WoNgUa8uqN1Vx6WAJw1JHPhglEGGHea6QICwJOAr/6mrui/oB7pkaWKHj3z7d1IC4KWLtY47elvjbaTlkN04Kc/5LFEirorGYVbt15kAUlqGM65pk6ZBxtaO3+30LVlORZkxOh+LKL/BvbZ/iRNhItLqNyieoQj/uh/7Iv4uyH/cV/0b4WDSd3DptigWq84lJubb9t/DnZlrJazxyDCulTmKdOR7vs9gMTo+uoIrPSb8ScTtvw65+odKAlBj59dhnVp9zd7QUojOpXlL62Aw56U4oO+FALuevvMjiWeavKhJqlR7i5n9srYcrNV7ttmDw7kf/97P5zauIhxcjX+xHv4M= 456 github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg= 457 github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl 458 github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphn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h93xSaua1N85qivl+siMkPGbO5xR/En4iEY6K2XPASUEMaieWVNTRCtJ4S8H+9 462 ssh.dev.azure.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7Hr1oTWqNqOlzGJOfGJ4NakVyIzf1rXYd4d7wo6jBlkLvCA4odBlL0mDUyZ0/QUfTTqeu+tm22gOsv+VrVTMk6vwRU75gY/y9ut5Mb3bR5BV58dKXyq9A9UeB5Cakehn5Zgm6x1mKoVyf+FFn26iYqXJRgzIZZcZ5V6hrE0Qg39kZm4az48o0AUbf6Sp4SLdvnuMa2sVNwHBboS7EJkm57XQPVU3/QpyNLHbWDdzwtrlS+ez30S3AdYhLKEOxAG8weOnyrtLJAUen9mTkol8oII1edf7mWWbWVf0nBmly21+nZcmCTISQBtdcyPaEno7fFQMDD26/s0lfKob4Kw8H 463 vs-ssh.visualstudio.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7Hr1oTWqNqOlzGJOfGJ4NakVyIzf1rXYd4d7wo6jBlkLvCA4odBlL0mDUyZ0/QUfTTqeu+tm22gOsv+VrVTMk6vwRU75gY/y9ut5Mb3bR5BV58dKXyq9A9UeB5Cakehn5Zgm6x1mKoVyf+FFn26iYqXJRgzIZZcZ5V6hrE0Qg39kZm4az48o0AUbf6Sp4SLdvnuMa2sVNwHBboS7EJkm57XQPVU3/QpyNLHbWDdzwtrlS+ez30S3AdYhLKEOxAG8weOnyrtLJAUen9mTkol8oII1edf7mWWbWVf0nBmly21+nZcmCTISQBtdcyPaEno7fFQMDD26/s0lfKob4Kw8H 464 ``` 465 466 !!! note 467 The `argocd-ssh-known-hosts-cm` ConfigMap will be mounted as a volume at the mount path `/app/config/ssh` in the pods of `argocd-server` and `argocd-repo-server`. It will create a file `ssh_known_hosts` in that directory, which contains the SSH known hosts data used by Argo CD for connecting to Git repositories via SSH. It might take a while for changes in the ConfigMap to be reflected in your pods, depending on your Kubernetes configuration. 468 469 ### Configure repositories with proxy 470 471 Proxy for your repository can be specified in the `proxy` field of the repository secret, along with other repository configurations. Argo CD uses this proxy to access the repository. Argo CD looks for the standard proxy environment variables in the repository server if the custom proxy is absent. 472 473 An example repository with proxy: 474 475 ```yaml 476 apiVersion: v1 477 kind: Secret 478 metadata: 479 name: private-repo 480 namespace: argocd 481 labels: 482 argocd.argoproj.io/secret-type: repository 483 stringData: 484 type: git 485 url: https://github.com/argoproj/private-repo 486 proxy: https://proxy-server-url:8888 487 password: my-password 488 username: my-username 489 ``` 490 491 ### Legacy behaviour 492 493 In Argo CD version 2.0 and earlier, repositories were stored as part of the `argocd-cm` config map. For 494 backward-compatibility, Argo CD will still honor repositories in the config map, but this style of repository 495 configuration is deprecated and support for it will be removed in a future version. 496 497 ```yaml 498 apiVersion: v1 499 kind: ConfigMap 500 data: 501 repositories: | 502 - url: https://github.com/argoproj/my-private-repository 503 passwordSecret: 504 name: my-secret 505 key: password 506 usernameSecret: 507 name: my-secret 508 key: username 509 repository.credentials: | 510 - url: https://github.com/argoproj 511 passwordSecret: 512 name: my-secret 513 key: password 514 usernameSecret: 515 name: my-secret 516 key: username 517 --- 518 apiVersion: v1 519 kind: Secret 520 metadata: 521 name: my-secret 522 namespace: argocd 523 stringData: 524 password: my-password 525 username: my-username 526 ``` 527 528 ## Clusters 529 530 Cluster credentials are stored in secrets same as repositories or repository credentials. Each secret must have label 531 `argocd.argoproj.io/secret-type: cluster`. 532 533 The secret data must include following fields: 534 535 * `name` - cluster name 536 * `server` - cluster api server url 537 * `namespaces` - optional comma-separated list of namespaces which are accessible in that cluster. Cluster level resources would be ignored if namespace list is not empty. 538 * `clusterResources` - optional boolean string (`"true"` or `"false"`) determining whether Argo CD can manage cluster-level resources on this cluster. This setting is used only if the list of managed namespaces is not empty. 539 * `project` - optional string to designate this as a project-scoped cluster. 540 * `config` - JSON representation of following data structure: 541 542 ```yaml 543 # Basic authentication settings 544 username: string 545 password: string 546 # Bearer authentication settings 547 bearerToken: string 548 # IAM authentication configuration 549 awsAuthConfig: 550 clusterName: string 551 roleARN: string 552 # Configure external command to supply client credentials 553 # See https://godoc.org/k8s.io/client-go/tools/clientcmd/api#ExecConfig 554 execProviderConfig: 555 command: string 556 args: [ 557 string 558 ] 559 env: { 560 key: value 561 } 562 apiVersion: string 563 installHint: string 564 # Transport layer security configuration settings 565 tlsClientConfig: 566 # Base64 encoded PEM-encoded bytes (typically read from a client certificate file). 567 caData: string 568 # Base64 encoded PEM-encoded bytes (typically read from a client certificate file). 569 certData: string 570 # Server should be accessed without verifying the TLS certificate 571 insecure: boolean 572 # Base64 encoded PEM-encoded bytes (typically read from a client certificate key file). 573 keyData: string 574 # ServerName is passed to the server for SNI and is used in the client to check server 575 # certificates against. If ServerName is empty, the hostname used to contact the 576 # server is used. 577 serverName: string 578 ``` 579 580 Note that if you specify a command to run under `execProviderConfig`, that command must be available in the Argo CD image. See [BYOI (Build Your Own Image)](custom_tools.md#byoi-build-your-own-image). 581 582 Cluster secret example: 583 584 ```yaml 585 apiVersion: v1 586 kind: Secret 587 metadata: 588 name: mycluster-secret 589 labels: 590 argocd.argoproj.io/secret-type: cluster 591 type: Opaque 592 stringData: 593 name: mycluster.example.com 594 server: https://mycluster.example.com 595 config: | 596 { 597 "bearerToken": "<authentication token>", 598 "tlsClientConfig": { 599 "insecure": false, 600 "caData": "<base64 encoded certificate>" 601 } 602 } 603 ``` 604 605 ### EKS 606 607 EKS cluster secret example using argocd-k8s-auth and [IRSA](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html): 608 609 ```yaml 610 apiVersion: v1 611 kind: Secret 612 metadata: 613 name: mycluster-secret 614 labels: 615 argocd.argoproj.io/secret-type: cluster 616 type: Opaque 617 stringData: 618 name: "mycluster.example.com" 619 server: "https://mycluster.example.com" 620 config: | 621 { 622 "awsAuthConfig": { 623 "clusterName": "my-eks-cluster-name", 624 "roleARN": "arn:aws:iam::<AWS_ACCOUNT_ID>:role/<IAM_ROLE_NAME>" 625 }, 626 "tlsClientConfig": { 627 "insecure": false, 628 "caData": "<base64 encoded certificate>" 629 } 630 } 631 ``` 632 633 Note that you should have IRSA enabled on your EKS cluster, create an appropriate IAM role which allows it to assume 634 other IAM roles (whichever `roleARN`s that Argo CD needs to assume) and have an assume role policy which allows 635 the argocd-application-controller and argocd-server pods to assume said role via OIDC. 636 637 Example trust relationship config for `<arn:aws:iam::<AWS_ACCOUNT_ID>:role/<ARGO_CD_MANAGEMENT_IAM_ROLE_NAME>`, which 638 is required for Argo CD to perform actions via IAM. Ensure that the cluster has an [IAM OIDC provider configured](https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html) 639 for it. 640 641 ```json 642 { 643 "Version": "2012-10-17", 644 "Statement": [ 645 { 646 "Effect": "Allow", 647 "Principal": { 648 "Federated": "arn:aws:iam::<AWS_ACCOUNT_ID>:oidc-provider/oidc.eks.<AWS_REGION>.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE" 649 }, 650 "Action": "sts:AssumeRoleWithWebIdentity", 651 "Condition": { 652 "StringEquals": { 653 "oidc.eks.<AWS_REGION>.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE:sub": ["system:serviceaccount:argocd:argocd-application-controller", "system:serviceaccount:argocd:argocd-server"], 654 "oidc.eks.<AWS_REGION>.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE:aud": "sts.amazonaws.com" 655 } 656 } 657 } 658 ] 659 } 660 ``` 661 662 The Argo CD management role also needs to be allowed to assume other roles, in this case we want it to assume 663 `arn:aws:iam::<AWS_ACCOUNT_ID>:role/<IAM_ROLE_NAME>` so that it can manage the cluster mapped to that role. This can be 664 extended to allow assumption of multiple roles, either as an explicit array of role ARNs or by using `*` where appropriate. 665 666 ```json 667 { 668 "Version" : "2012-10-17", 669 "Statement" : { 670 "Effect" : "Allow", 671 "Action" : "sts:AssumeRole", 672 "Principal" : { 673 "AWS" : "<arn:aws:iam::<AWS_ACCOUNT_ID>:role/<IAM_ROLE_NAME>" 674 } 675 } 676 } 677 ``` 678 679 Example service account configs for `argocd-application-controller` and `argocd-server`. 680 681 !!! warning 682 Once the annotations have been set on the service accounts, both the application controller and server pods need to be restarted. 683 684 ```yaml 685 apiVersion: v1 686 kind: ServiceAccount 687 metadata: 688 annotations: 689 eks.amazonaws.com/role-arn: "<arn:aws:iam::<AWS_ACCOUNT_ID>:role/<ARGO_CD_MANAGEMENT_IAM_ROLE_NAME>" 690 name: argocd-application-controller 691 --- 692 apiVersion: v1 693 kind: ServiceAccount 694 metadata: 695 annotations: 696 eks.amazonaws.com/role-arn: "<arn:aws:iam::<AWS_ACCOUNT_ID>:role/<ARGO_CD_MANAGEMENT_IAM_ROLE_NAME>" 697 name: argocd-server 698 ``` 699 700 In turn, the `roleARN` of each managed cluster needs to be added to each respective cluster's `aws-auth` config map (see 701 [Enabling IAM principal access to your cluster](https://docs.aws.amazon.com/eks/latest/userguide/add-user-role.html)), as 702 well as having an assume role policy which allows it to be assumed by the Argo CD pod role. 703 704 Example assume role policy for a cluster which is managed by Argo CD: 705 706 ```json 707 { 708 "Version" : "2012-10-17", 709 "Statement" : { 710 "Effect" : "Allow", 711 "Action" : "sts:AssumeRole", 712 "Principal" : { 713 "AWS" : "<arn:aws:iam::<AWS_ACCOUNT_ID>:role/<ARGO_CD_MANAGEMENT_IAM_ROLE_NAME>" 714 } 715 } 716 } 717 ``` 718 719 Example kube-system/aws-auth configmap for your cluster managed by Argo CD: 720 721 ```yaml 722 apiVersion: v1 723 data: 724 # Other groups and accounts omitted for brevity. Ensure that no other rolearns and/or groups are inadvertently removed, 725 # or you risk borking access to your cluster. 726 # 727 # The group name is a RoleBinding which you use to map to a [Cluster]Role. See https://kubernetes.io/docs/reference/access-authn-authz/rbac/#role-binding-examples 728 mapRoles: | 729 - "groups": 730 - "<GROUP-NAME-IN-K8S-RBAC>" 731 "rolearn": "<arn:aws:iam::<AWS_ACCOUNT_ID>:role/<IAM_ROLE_NAME>" 732 "username": "<some-username>" 733 ``` 734 ### GKE 735 736 GKE cluster secret example using argocd-k8s-auth and [Workload Identity](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity): 737 738 ```yaml 739 apiVersion: v1 740 kind: Secret 741 metadata: 742 name: mycluster-secret 743 labels: 744 argocd.argoproj.io/secret-type: cluster 745 type: Opaque 746 stringData: 747 name: mycluster.example.com 748 server: https://mycluster.example.com 749 config: | 750 { 751 "execProviderConfig": { 752 "command": "argocd-k8s-auth", 753 "args": ["gcp"], 754 "apiVersion": "client.authentication.k8s.io/v1beta1" 755 }, 756 "tlsClientConfig": { 757 "insecure": false, 758 "caData": "<base64 encoded certificate>" 759 } 760 } 761 ``` 762 763 Note that you must enable Workload Identity on your GKE cluster, create GCP service account with appropriate IAM role and bind it to Kubernetes service account for argocd-application-controller and argocd-server (showing Pod logs on UI). See [Use Workload Identity](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity) and [Authenticating to the Kubernetes API server](https://cloud.google.com/kubernetes-engine/docs/how-to/api-server-authentication). 764 765 ### AKS 766 767 Azure cluster secret example using argocd-k8s-auth and [kubelogin](https://github.com/Azure/kubelogin). The option *azure* to the argocd-k8s-auth execProviderConfig encapsulates the *get-token* command for kubelogin. Depending upon which authentication flow is desired (devicecode, spn, ropc, msi, azurecli, workloadidentity), set the environment variable AAD_LOGIN_METHOD with this value. Set other appropriate environment variables depending upon which authentication flow is desired. 768 769 |Variable Name|Description| 770 |-------------|-----------| 771 |AAD_LOGIN_METHOD|One of devicecode, spn, ropc, msi, azurecli, or workloadidentity| 772 |AAD_SERVICE_PRINCIPAL_CLIENT_CERTIFICATE|AAD client cert in pfx. Used in spn login| 773 |AAD_SERVICE_PRINCIPAL_CLIENT_ID|AAD client application ID| 774 |AAD_SERVICE_PRINCIPAL_CLIENT_SECRET|AAD client application secret| 775 |AAD_USER_PRINCIPAL_NAME|Used in the ropc flow| 776 |AAD_USER_PRINCIPAL_PASSWORD|Used in the ropc flow| 777 |AZURE_TENANT_ID|The AAD tenant ID.| 778 |AZURE_AUTHORITY_HOST|Used in the WorkloadIdentityLogin flow| 779 |AZURE_FEDERATED_TOKEN_FILE|Used in the WorkloadIdentityLogin flow| 780 |AZURE_CLIENT_ID|Used in the WorkloadIdentityLogin flow| 781 782 In addition to the environment variables above, argocd-k8s-auth accepts two extra environment variables to set the AAD environment, and to set the AAD server application ID. The AAD server application ID will default to 6dae42f8-4368-4678-94ff-3960e28e3630 if not specified. See [here](https://github.com/azure/kubelogin#exec-plugin-format) for details. 783 784 |Variable Name|Description| 785 |-------------|-----------| 786 |AAD_ENVIRONMENT_NAME|The azure environment to use, default of AzurePublicCloud| 787 |AAD_SERVER_APPLICATION_ID|The optional AAD server application ID, defaults to 6dae42f8-4368-4678-94ff-3960e28e3630| 788 789 This is an example of using the [federated workload login flow](https://github.com/Azure/kubelogin#azure-workload-federated-identity-non-interactive). The federated token file needs to be mounted as a secret into argoCD, so it can be used in the flow. The location of the token file needs to be set in the environment variable AZURE_FEDERATED_TOKEN_FILE. 790 791 ```yaml 792 apiVersion: v1 793 kind: Secret 794 metadata: 795 name: mycluster-secret 796 labels: 797 argocd.argoproj.io/secret-type: cluster 798 type: Opaque 799 stringData: 800 name: mycluster.example.com 801 server: https://mycluster.example.com 802 config: | 803 { 804 "execProviderConfig": { 805 "command": "argocd-k8s-auth", 806 "env": { 807 "AAD_ENVIRONMENT_NAME": "AzurePublicCloud", 808 "AZURE_CLIENT_ID": "fill in client id", 809 "AZURE_TENANT_ID": "fill in tenant id", 810 "AZURE_FEDERATED_TOKEN_FILE": "/opt/path/to/federated_file.json", 811 "AZURE_AUTHORITY_HOST": "https://login.microsoftonline.com/", 812 "AAD_LOGIN_METHOD": "workloadidentity" 813 }, 814 "args": ["azure"], 815 "apiVersion": "client.authentication.k8s.io/v1beta1" 816 }, 817 "tlsClientConfig": { 818 "insecure": false, 819 "caData": "<base64 encoded certificate>" 820 } 821 } 822 ``` 823 824 This is an example of using the spn (service principal name) flow. 825 826 ```yaml 827 apiVersion: v1 828 kind: Secret 829 metadata: 830 name: mycluster-secret 831 labels: 832 argocd.argoproj.io/secret-type: cluster 833 type: Opaque 834 stringData: 835 name: mycluster.example.com 836 server: https://mycluster.example.com 837 config: | 838 { 839 "execProviderConfig": { 840 "command": "argocd-k8s-auth", 841 "env": { 842 "AAD_ENVIRONMENT_NAME": "AzurePublicCloud", 843 "AAD_SERVICE_PRINCIPAL_CLIENT_SECRET": "fill in your service principal client secret", 844 "AZURE_TENANT_ID": "fill in tenant id", 845 "AAD_SERVICE_PRINCIPAL_CLIENT_ID": "fill in your service principal client id", 846 "AAD_LOGIN_METHOD": "spn" 847 }, 848 "args": ["azure"], 849 "apiVersion": "client.authentication.k8s.io/v1beta1" 850 }, 851 "tlsClientConfig": { 852 "insecure": false, 853 "caData": "<base64 encoded certificate>" 854 } 855 } 856 ``` 857 858 ## Helm Chart Repositories 859 860 Non standard Helm Chart repositories have to be registered explicitly. 861 Each repository must have `url`, `type` and `name` fields. For private Helm repos you may need to configure access credentials and HTTPS settings using `username`, `password`, 862 `tlsClientCertData` and `tlsClientCertKey` fields. 863 864 Example: 865 866 ```yaml 867 apiVersion: v1 868 kind: Secret 869 metadata: 870 name: istio 871 namespace: argocd 872 labels: 873 argocd.argoproj.io/secret-type: repository 874 stringData: 875 name: istio.io 876 url: https://storage.googleapis.com/istio-prerelease/daily-build/master-latest-daily/charts 877 type: helm 878 --- 879 apiVersion: v1 880 kind: Secret 881 metadata: 882 name: argo-helm 883 namespace: argocd 884 labels: 885 argocd.argoproj.io/secret-type: repository 886 stringData: 887 name: argo 888 url: https://argoproj.github.io/argo-helm 889 type: helm 890 username: my-username 891 password: my-password 892 tlsClientCertData: ... 893 tlsClientCertKey: ... 894 ``` 895 896 ## Resource Exclusion/Inclusion 897 898 Resources can be excluded from discovery and sync so that Argo CD is unaware of them. For example, the apiGroup/kind `events.k8s.io/*`, `metrics.k8s.io/*`, `coordination.k8s.io/Lease`, and `""/Endpoints` are always excluded. Use cases: 899 900 * You have temporal issues and you want to exclude problematic resources. 901 * There are many of a kind of resources that impacts Argo CD's performance. 902 * Restrict Argo CD's access to certain kinds of resources, e.g. secrets. See [security.md#cluster-rbac](security.md#cluster-rbac). 903 904 To configure this, edit the `argocd-cm` config map: 905 906 ```shell 907 kubectl edit configmap argocd-cm -n argocd 908 ``` 909 910 Add `resource.exclusions`, e.g.: 911 912 ```yaml 913 apiVersion: v1 914 data: 915 resource.exclusions: | 916 - apiGroups: 917 - "*" 918 kinds: 919 - "*" 920 clusters: 921 - https://192.168.0.20 922 kind: ConfigMap 923 ``` 924 925 The `resource.exclusions` node is a list of objects. Each object can have: 926 927 * `apiGroups` A list of globs to match the API group. 928 * `kinds` A list of kinds to match. Can be `"*"` to match all. 929 * `clusters` A list of globs to match the cluster. 930 931 If all three match, then the resource is ignored. 932 933 In addition to exclusions, you might configure the list of included resources using the `resource.inclusions` setting. 934 By default, all resource group/kinds are included. The `resource.inclusions` setting allows customizing the list of included group/kinds: 935 936 ```yaml 937 apiVersion: v1 938 data: 939 resource.inclusions: | 940 - apiGroups: 941 - "*" 942 kinds: 943 - Deployment 944 clusters: 945 - https://192.168.0.20 946 kind: ConfigMap 947 ``` 948 949 The `resource.inclusions` and `resource.exclusions` might be used together. The final list of resources includes group/kinds specified in `resource.inclusions` minus group/kinds 950 specified in `resource.exclusions` setting. 951 952 Notes: 953 954 * Quote globs in your YAML to avoid parsing errors. 955 * Invalid globs result in the whole rule being ignored. 956 * If you add a rule that matches existing resources, these will appear in the interface as `OutOfSync`. 957 958 ## Auto respect RBAC for controller 959 960 Argocd controller can be restricted from discovering/syncing specific resources using just controller rbac, without having to manually configure resource exclusions. 961 This feature can be enabled by setting `resource.respectRBAC` key in argocd cm, once it is set the controller will automatically stop watching for resources 962 that it does not have the permission to list/access. Possible values for `resource.respectRBAC` are: 963 - `strict` : This setting checks whether the list call made by controller is forbidden/unauthorized and if it is, it will cross-check the permission by making a `SelfSubjectAccessReview` call for the resource. 964 - `normal` : This will only check whether the list call response is forbidden/unauthorized and skip `SelfSubjectAccessReview` call, to minimize any extra api-server calls. 965 - unset/empty (default) : This will disable the feature and controller will continue to monitor all resources. 966 967 Users who are comfortable with an increase in kube api-server calls can opt for `strict` option while users who are concerned with higher api calls and are willing to compromise on the accuracy can opt for the `normal` option. 968 969 Notes: 970 971 * When set to use `strict` mode controller must have rbac permission to `create` a `SelfSubjectAccessReview` resource 972 * The `SelfSubjectAccessReview` request will be only made for the `list` verb, it is assumed that if `list` is allowed for a resource then all other permissions are also available to the controller. 973 974 Example argocd cm with `resource.respectRBAC` set to `strict`: 975 976 ```yaml 977 apiVersion: v1 978 kind: ConfigMap 979 metadata: 980 name: argocd-cm 981 data: 982 resource.respectRBAC: "strict" 983 ``` 984 985 ## Resource Custom Labels 986 987 Custom Labels configured with `resource.customLabels` (comma separated string) will be displayed in the UI (for any resource that defines them). 988 989 ## SSO & RBAC 990 991 * SSO configuration details: [SSO](./user-management/index.md) 992 * RBAC configuration details: [RBAC](./rbac.md) 993 994 ## Manage Argo CD Using Argo CD 995 996 Argo CD is able to manage itself since all settings are represented by Kubernetes manifests. The suggested way is to create [Kustomize](https://github.com/kubernetes-sigs/kustomize) 997 based application which uses base Argo CD manifests from [https://github.com/argoproj/argo-cd](https://github.com/argoproj/argo-cd/tree/stable/manifests) and apply required changes on top. 998 999 Example of `kustomization.yaml`: 1000 1001 ```yaml 1002 # additional resources like ingress rules, cluster and repository secrets. 1003 resources: 1004 - github.com/argoproj/argo-cd//manifests/cluster-install?ref=v1.0.1 1005 - clusters-secrets.yaml 1006 - repos-secrets.yaml 1007 1008 # changes to config maps 1009 patches: 1010 - path: overlays/argo-cd-cm.yaml 1011 ``` 1012 1013 The live example of self managed Argo CD config is available at [https://cd.apps.argoproj.io](https://cd.apps.argoproj.io) and with configuration 1014 stored at [argoproj/argoproj-deployments](https://github.com/argoproj/argoproj-deployments/tree/master/argocd). 1015 1016 !!! note 1017 You will need to sign-in using your GitHub account to get access to [https://cd.apps.argoproj.io](https://cd.apps.argoproj.io)