Declarative Setup
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.
Quick Reference
All resources, including Application and AppProject specs, have to be installed in the Argo CD namespace (by default argocd).
Atomic configuration
| Sample File | Resource Name | Kind | Description |
|---|---|---|---|
| argocd-cm.yaml | argocd-cm | ConfigMap | General Argo CD configuration |
| argocd-repositories.yaml | my-private-repo / istio-helm-repo / private-helm-repo / private-repo | Secrets | Sample repository connection details |
| argocd-repo-creds.yaml | argoproj-https-creds / argoproj-ssh-creds / github-creds / github-enterprise-creds | Secrets | Sample repository credential templates |
| argocd-cmd-params-cm.yaml | argocd-cmd-params-cm | ConfigMap | Argo CD env variables configuration |
| argocd-secret.yaml | argocd-secret | Secret | User Passwords, Certificates (deprecated), Signing Key, Dex secrets, Webhook secrets |
| argocd-rbac-cm.yaml | argocd-rbac-cm | ConfigMap | RBAC Configuration |
| argocd-tls-certs-cm.yaml | argocd-tls-certs-cm | ConfigMap | Custom TLS certificates for connecting Git repositories via HTTPS (v1.2 and later) |
| argocd-ssh-known-hosts-cm.yaml | argocd-ssh-known-hosts-cm | ConfigMap | SSH known hosts data for connecting Git repositories via SSH (v1.2 and later) |
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.
A note about ConfigMap resources
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.
Multiple configuration objects
| Sample File | Kind | Description |
|---|---|---|
| application.yaml | Application | Example application spec |
| project.yaml | AppProject | Example project spec |
| - | Secret | Repository credentials |
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.
Applications
The Application CRD is the Kubernetes resource object representing a deployed application instance in an environment. It is defined by two key pieces of information:
sourcereference to the desired state in Git (repository, revision, path, environment)destinationreference 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.
A minimal Application spec is as follows:
apiVersion: argoproj.io/v1alpha1kind: Applicationmetadata:name: guestbooknamespace: argocdspec:project: defaultsource:repoURL: https://github.com/argoproj/argocd-example-apps.gittargetRevision: HEADpath: guestbookdestination:server: https://kubernetes.default.svcnamespace: guestbook
See application.yaml for additional fields. As long as you have completed the first step of Getting Started, you can apply this with kubectl apply -n argocd -f application.yaml and Argo CD will start deploying the guestbook application.
Note
The namespace must match the namespace of your Argo CD instance - typically this is argocd.
Note
When creating an application from a Helm repository, the chart attribute must be specified instead of the path attribute within spec.source.
spec:source:repoURL: https://argoproj.github.io/argo-helmchart: argo
Warning
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.
metadata:finalizers:- resources-finalizer.argocd.argoproj.io
App of Apps
You can create an app that creates other apps, which in turn can create other apps. This allows you to declaratively manage a group of apps that can be deployed and configured in concert.
Projects
The AppProject CRD is the Kubernetes resource object representing a logical grouping of applications. It is defined by the following key pieces of information:
sourceReposreference to the repositories that applications within the project can pull manifests from.destinationsreference to clusters and namespaces that applications within the project can deploy into (don’t use thenamefield, only theserverfield is matched).roleslist of entities with definitions of their access to resources within the project.
Projects which can deploy to the Argo CD namespace grant admin access
If a Project’s destinations configuration allows deploying to the namespace in which Argo CD is installed, then Applications under that project have admin-level access. RBAC access to admin-level Projects should be carefully restricted, and push access to allowed sourceRepos should be limited to only admins.
An example spec is as follows:
apiVersion: argoproj.io/v1alpha1kind: AppProjectmetadata:name: my-projectnamespace: argocd# Finalizer that ensures that project is not deleted until it is not referenced by any applicationfinalizers:- resources-finalizer.argocd.argoproj.iospec:description: Example Project# Allow manifests to deploy from any Git repossourceRepos:- '*'# Only permit applications to deploy to the guestbook namespace in the same clusterdestinations:- namespace: guestbookserver: https://kubernetes.default.svc# Deny all cluster-scoped resources from being created, except for NamespaceclusterResourceWhitelist:- group: ''kind: Namespace# Allow all namespaced-scoped resources to be created, except for ResourceQuota, LimitRange, NetworkPolicynamespaceResourceBlacklist:- group: ''kind: ResourceQuota- group: ''kind: LimitRange- group: ''kind: NetworkPolicy# Deny all namespaced-scoped resources from being created, except for Deployment and StatefulSetnamespaceResourceWhitelist:- group: 'apps'kind: Deployment- group: 'apps'kind: StatefulSetroles:# A role which provides read-only access to all applications in the project- name: read-onlydescription: Read-only privileges to my-projectpolicies:- p, proj:my-project:read-only, applications, get, my-project/*, allowgroups:- my-oidc-group# A role which provides sync privileges to only the guestbook-dev application, e.g. to provide# sync privileges to a CI system- name: ci-roledescription: Sync privileges for guestbook-devpolicies:- p, proj:my-project:ci-role, applications, sync, my-project/guestbook-dev, allow# NOTE: JWT tokens can only be generated by the API server and the token is not persisted# anywhere by Argo CD. It can be prematurely revoked by removing the entry from this list.jwtTokens:- iat: 1535390316
Repositories
Note
Some Git hosters - notably GitLab and possibly on-premise GitLab instances as well - require you to specify the .git suffix in the repository URL, otherwise they will send a HTTP 301 redirect to the repository URL suffixed with .git. Argo CD will not follow these redirects, so you have to adjust your repository URL to be suffixed with .git.
Repository details are stored in secrets. To configure a repo, create a secret which contains repository details. Consider using bitnami-labs/sealed-secrets to store an encrypted secret definition as a Kubernetes manifest. 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).
Warning
When using bitnami-labs/sealed-secrets the labels will be removed and have to be readded as descibed here: https://github.com/bitnami-labs/sealed-secrets#sealedsecrets-as-templates-for-secrets
Example for HTTPS:
apiVersion: v1kind: Secretmetadata:name: private-reponamespace: argocdlabels:argocd.argoproj.io/secret-type: repositorystringData:type: giturl: https://github.com/argoproj/private-repopassword: my-passwordusername: my-username
Example for SSH:
apiVersion: v1kind: Secretmetadata:name: private-reponamespace: argocdlabels:argocd.argoproj.io/secret-type: repositorystringData:type: giturl: git@github.com:argoproj/my-private-repositorysshPrivateKey: |-----BEGIN OPENSSH PRIVATE KEY-----...-----END OPENSSH PRIVATE KEY-----
Example for GitHub App:
apiVersion: v1kind: Secretmetadata:name: github-reponamespace: argocdlabels:argocd.argoproj.io/secret-type: repositorystringData:type: giturl: https://github.com/argoproj/my-private-repositorygithubAppID: 1githubAppInstallationID: 2githubAppPrivateKey: |-----BEGIN OPENSSH PRIVATE KEY-----...-----END OPENSSH PRIVATE KEY--------apiVersion: v1kind: Secretmetadata:name: github-enterprise-reponamespace: argocdlabels:argocd.argoproj.io/secret-type: repositorystringData:type: giturl: https://ghe.example.com/argoproj/my-private-repositorygithubAppID: 1githubAppInstallationID: 2githubAppEnterpriseBaseUrl: https://ghe.example.com/api/v3githubAppPrivateKey: |-----BEGIN OPENSSH PRIVATE KEY-----...-----END OPENSSH PRIVATE KEY-----
Tip
The Kubernetes documentation has instructions for creating a secret containing a private key.
Repository Credentials
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.
apiVersion: v1kind: Secretmetadata:name: first-reponamespace: argocdlabels:argocd.argoproj.io/secret-type: repositorystringData:type: giturl: https://github.com/argoproj/private-repo---apiVersion: v1kind: Secretmetadata:name: second-reponamespace: argocdlabels:argocd.argoproj.io/secret-type: repositorystringData:type: giturl: https://github.com/argoproj/other-private-repo---apiVersion: v1kind: Secretmetadata:name: private-repo-credsnamespace: argocdlabels:argocd.argoproj.io/secret-type: repo-credsstringData:type: giturl: https://github.com/argoprojpassword: my-passwordusername: my-username
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.
In order for Argo CD to use a credential template for any given repository, the following conditions must be met:
- 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) - 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).
Note
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.
The following keys are valid to refer to credential secrets:
SSH repositories
sshPrivateKeyrefers to the SSH private key for accessing the repositories
HTTPS repositories
usernameandpasswordrefer to the username and/or password for accessing the repositoriestlsClientCertDataandtlsClientCertKeyrefer to secrets where a TLS client certificate (tlsClientCertData) and the corresponding private keytlsClientCertKeyare stored for accessing the repositories
GitHub App repositories
githubAppPrivateKeyrefers to the GitHub App private key for accessing the repositoriesgithubAppIDrefers to the GitHub Application ID for the application you created.githubAppInstallationIDrefers to the Installation ID of the GitHub app you created and installed.githubAppEnterpriseBaseUrlrefers to the base api URL for GitHub Enterprise (e.g.https://ghe.example.com/api/v3)tlsClientCertDataandtlsClientCertKeyrefer to secrets where a TLS client certificate (tlsClientCertData) and the corresponding private keytlsClientCertKeyare stored for accessing GitHub Enterprise if custom certificates are used.
Repositories using self-signed TLS certificates (or are signed by custom CA)
v1.2 or later
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.
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.
An example ConfigMap object:
apiVersion: v1kind: ConfigMapmetadata:name: argocd-tls-certs-cmnamespace: argocdlabels:app.kubernetes.io/name: argocd-cmapp.kubernetes.io/part-of: argocddata:server.example.com: |-----BEGIN CERTIFICATE-----MIIF1zCCA7+gAwIBAgIUQdTcSHY2Sxd3Tq/v1eIEZPCNbOowDQYJKoZIhvcNAQELBQAwezELMAkGA1UEBhMCREUxFTATBgNVBAgMDExvd2VyIFNheG9ueTEQMA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4C4hQpey86r6+x1ewwHwYDVR0jBBgwFoAUjXH6PHi92y4C4hQpey86r6+x1ewwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAFE4SdKsX9UsLy+Z0xuHSxhTd0jfnIih5mtzb8CDNO5oTw4z0aMeAvpsUvjJ/XjgxnkiRACXh7K9hsG2r+ageRWGevyvxCaRXFbherV1kTnZw4Y9/pgZTYVWs9jlqFOppz5sStkfjsDQ5lmPJGDii/StENAz2XmtiPOgfG9Upb0GAJBCuKnrU9bIcT4L20gd2F4Y14ccyjlf8UiUi192IX6yM9OjT+TuXwZgqnTOq6piVgr+FTSa24qSvaXb5z/mJDLlk23npecTouLg83TNSn3R6fYQrd/Y9eXuUJ8U7/qTh2Ulz071AO9KzPOmleYPTx4Xty4xAtWi1QE5NHW9/Ajlv5OtOOnMNWIs7ssDJBsB7VFC8hcwf79jz7kC0xmQqDfw51Xhhk04kla+v+HZcFW2AO9so6ZdVHHQnIbJa7yQJKZ+hK49IOoBR6JgdB5kymoplLLiuqZSYTcwSBZ72FYTm3iArjzvt1hxpxVDmXvRnkhRrIRhK4QgJL0jRmirBjDY+PYYd7bdRIjN7WNZLFsgplnS89w6CwG32pRlm0c8kkiQ7FXA6BYCqOsDI8f1VGQv331OpR2Ck+FTv+L7DAmg6l37W+LB9LGh4OAp68ImTjqf6ioGKG0RBSznwME+r4nXtT1S/qLR6ASWUS4ViWRhbRlNKXWyb96wrUlv+E8I=-----END CERTIFICATE-----
Note
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.
SSH known host public keys
If you are connecting repositories via SSH, Argo CD will need to know the SSH known hosts public key of the repository servers. You can manage the SSH known hosts data in the ConfigMap named argocd-ssh-known-hosts-cm. This ConfigMap contains a single key/value pair, with ssh_known_hosts as the key and the actual public keys of the SSH servers as data. As opposed to TLS configuration, the public key(s) of each single repository server Argo CD will connect via SSH must be configured, otherwise the connections to the repository will fail. There is no fallback. The data can be copied from any existing ssh_known_hosts file, or from the output of the ssh-keyscan utility. The basic format is <servername> <keydata>, one entry per line.
An example ConfigMap object:
apiVersion: v1kind: ConfigMapmetadata:name: argocd-ssh-known-hosts-cmnamespace: argocdlabels:app.kubernetes.io/name: argocd-cmapp.kubernetes.io/part-of: argocddata:ssh_known_hosts: |bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==gitlab.com ecdsa-sha2-nistp256 AAAAE2V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Yd4d7wo6jBlkLvCA4odBlL0mDUyZ0/QUfTTqeu+tm22gOsv+VrVTMk6vwRU75gY/y9ut5Mb3bR5BV58dKXyq9A9UeB5Cakehn5Zgm6x1mKoVyf+FFn26iYqXJRgzIZZcZ5V6hrE0Qg39kZm4az48o0AUbf6Sp4SLdvnuMa2sVNwHBboS7EJkm57XQPVU3/QpyNLHbWDdzwtrlS+ez30S3AdYhLKEOxAG8weOnyrtLJAUen9mTkol8oII1edf7mWWbWVf0nBmly21+nZcmCTISQBtdcyPaEno7fFQMDD26/s0lfKob4Kw8Hgithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl
Note
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.
Configure repositories with proxy
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.
An example repository with proxy:
apiVersion: v1kind: Secretmetadata:name: private-reponamespace: argocdlabels:argocd.argoproj.io/secret-type: repositorystringData:type: giturl: https://github.com/argoproj/private-repoproxy: https://proxy-server-url:8888password: my-passwordusername: my-username
Legacy behaviour
In Argo CD version 2.0 and earlier, repositories where stored as part of the argocd-cm config map. For backward-compatibility, Argo CD will still honor repositories in the config map, but this style of repository configuration is deprecated and support for it will be removed in a future version.
apiVersion: v1kind: ConfigMapdata:repositories: |- url: https://github.com/argoproj/my-private-repositorypasswordSecret:name: my-secretkey: passwordusernameSecret:name: my-secretkey: usernamerepository.credentials: |- url: https://github.com/argoprojpasswordSecret:name: my-secretkey: passwordusernameSecret:name: my-secretkey: username---apiVersion: v1kind: Secretmetadata:name: my-secretnamespace: argocdstringData:password: my-passwordusername: my-username
Clusters
Cluster credentials are stored in secrets same as repositories or repository credentials. Each secret must have label argocd.argoproj.io/secret-type: cluster.
The secret data must include following fields:
name- cluster nameserver- cluster api server urlnamespaces- optional comma-separated list of namespaces which are accessible in that cluster. Cluster level resources would be ignored if namespace list is not empty.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.config- JSON representation of following data structure:
# Basic authentication settingsusername: stringpassword: string# Bearer authentication settingsbearerToken: string# IAM authentication configurationawsAuthConfig:clusterName: stringroleARN: string# Configure external command to supply client credentials# See https://godoc.org/k8s.io/client-go/tools/clientcmd/api#ExecConfigexecProviderConfig:command: stringargs: [string]env: {key: value}apiVersion: stringinstallHint: string# Transport layer security configuration settingstlsClientConfig:# Base64 encoded PEM-encoded bytes (typically read from a client certificate file).caData: string# Base64 encoded PEM-encoded bytes (typically read from a client certificate file).certData: string# Server should be accessed without verifying the TLS certificateinsecure: boolean# Base64 encoded PEM-encoded bytes (typically read from a client certificate key file).keyData: string# ServerName is passed to the server for SNI and is used in the client to check server# certificates against. If ServerName is empty, the hostname used to contact the# server is used.serverName: string
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).
Cluster secret example:
apiVersion: v1kind: Secretmetadata:name: mycluster-secretlabels:argocd.argoproj.io/secret-type: clustertype: OpaquestringData:name: mycluster.comserver: https://mycluster.comconfig: |{"bearerToken": "<authentication token>","tlsClientConfig": {"insecure": false,"caData": "<base64 encoded certificate>"}}
GKE cluster secret example using argocd-k8s-auth and Workload Identity:
apiVersion: v1kind: Secretmetadata:name: mycluster-secretlabels:argocd.argoproj.io/secret-type: clustertype: OpaquestringData:name: mycluster.comserver: https://mycluster.comconfig: |{"execProviderConfig": {"command": "argocd-k8s-auth","args": ["gcp"],"apiVersion": "client.authentication.k8s.io/v1beta1"},"tlsClientConfig": {"insecure": false,"caData": "<base64 encoded certificate>"}}
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 and Authenticating to the Kubernetes API server.
Helm Chart Repositories
Non standard Helm Chart repositories have to be registered explicitly. 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, tlsClientCertData and tlsClientCertKey fields.
Example:
apiVersion: v1kind: Secretmetadata:name: istionamespace: argocdlabels:argocd.argoproj.io/secret-type: repositorystringData:name: istio.iourl: https://storage.googleapis.com/istio-prerelease/daily-build/master-latest-daily/chartstype: helm---apiVersion: v1kind: Secretmetadata:name: argo-helmnamespace: argocdlabels:argocd.argoproj.io/secret-type: repositorystringData:name: argourl: https://argoproj.github.io/argo-helmtype: helmusername: my-usernamepassword: my-passwordtlsClientCertData: ...tlsClientCertKey: ...
Resource Exclusion/Inclusion
Resources can be excluded from discovery and sync so that Argo CD is unaware of them. For example, events.k8s.io and metrics.k8s.io are always excluded. Use cases:
- You have temporal issues and you want to exclude problematic resources.
- There are many of a kind of resources that impacts Argo CD’s performance.
- Restrict Argo CD’s access to certain kinds of resources, e.g. secrets. See security.md#cluster-rbac.
To configure this, edit the argocd-cm config map:
kubectl edit configmap argocd-cm -n argocd
Add resource.exclusions, e.g.:
apiVersion: v1data:resource.exclusions: |- apiGroups:- "*"kinds:- "*"clusters:- https://192.168.0.20kind: ConfigMap
The resource.exclusions node is a list of objects. Each object can have:
apiGroupsA list of globs to match the API group.kindsA list of kinds to match. Can be"*"to match all.clustersA list of globs to match the cluster.
If all three match, then the resource is ignored.
In addition to exclusions, you might configure the list of included resources using the resource.inclusions setting. By default, all resource group/kinds are included. The resource.inclusions setting allows customizing the list of included group/kinds:
apiVersion: v1data:resource.inclusions: |- apiGroups:- "*"kinds:- Deploymentclusters:- https://192.168.0.20kind: ConfigMap
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 specified in resource.exclusions setting.
Notes:
- Quote globs in your YAML to avoid parsing errors.
- Invalid globs result in the whole rule being ignored.
- If you add a rule that matches existing resources, these will appear in the interface as
OutOfSync.
SSO & RBAC
Manage Argo CD Using Argo CD
Argo CD is able to manage itself since all settings are represented by Kubernetes manifests. The suggested way is to create Kustomize based application which uses base Argo CD manifests from https://github.com/argoproj/argo-cd and apply required changes on top.
Example of kustomization.yaml:
bases:- github.com/argoproj/argo-cd//manifests/cluster-install?ref=v1.0.1# additional resources like ingress rules, cluster and repository secrets.resources:- clusters-secrets.yaml- repos-secrets.yaml# changes to config mapspatchesStrategicMerge:- overlays/argo-cd-cm.yaml
The live example of self managed Argo CD config is available at https://cd.apps.argoproj.io and with configuration stored at argoproj/argoproj-deployments.
Note
You will need to sign-in using your GitHub account to get access to https://cd.apps.argoproj.io