argo-cd/docs/user-guide/parameters.md

91 lines
4.7 KiB
Markdown
Raw Normal View History

# Parameter Overrides
Argo CD provides a mechanism to override the parameters of Argo CD applications that leverages config management
tools. This provides flexibility in having most of the application manifests defined in Git, while leaving room
for *some* parts of the k8s manifests determined dynamically, or outside of Git. It also serves as an alternative way of
2019-01-12 23:50:38 +00:00
redeploying an application by changing application parameters via Argo CD, instead of making the
changes to the manifests in Git.
!!! tip
Many consider this mode of operation as an anti-pattern to GitOps, since the source of
truth becomes a union of the Git repository, and the application overrides. The Argo CD parameter
overrides feature is provided mainly as a convenience to developers and is intended to be used in
dev/test environments, vs. production environments.
To use parameter overrides, run the `argocd app set -p (COMPONENT=)PARAM=VALUE` command:
```bash
argocd app set guestbook -p image=example/guestbook:abcd123
argocd app sync guestbook
```
The `PARAM` is expected to be a normal YAML path
```bash
argocd app set guestbook -p ingress.enabled=true
argocd app set guestbook -p ingress.hosts[0]=guestbook.myclusterurl
```
The `argocd app set` [command](./commands/argocd_app_set.md) supports more tool-specific flags such as `--kustomize-image`, `--jsonnet-ext-var-str`, etc.
You can also specify overrides directly in the source field on the application spec. Read more about supported options in the corresponding tool [documentation](./application_sources.md).
## When To Use Overrides?
The following are situations where parameter overrides would be useful:
1. A team maintains a "dev" environment, which needs to be continually updated with the latest
version of their guestbook application after every build in the tip of master. To address this use
2019-01-12 23:50:38 +00:00
case, the application would expose a parameter named `image`, whose value used in the `dev`
environment contains a placeholder value (e.g. `example/guestbook:replaceme`). The placeholder value
would be determined externally (outside of Git) such as a build system. Then, as part of the build
pipeline, the parameter value of the `image` would be continually updated to the freshly built image
(e.g. `argocd app set guestbook -p image=example/guestbook:abcd123`). A sync operation
would result in the application being redeployed with the new image.
2019-01-12 23:50:38 +00:00
2. A repository of Helm manifests is already publicly available (e.g. https://github.com/helm/charts).
Since commit access to the repository is unavailable, it is useful to be able to install charts from
2019-01-12 23:50:38 +00:00
the public repository and customize the deployment with different parameters, without resorting to
forking the repository to make the changes. For example, to install Redis from the Helm chart
repository and customize the database password, you would run:
```bash
argocd app create redis --repo https://github.com/helm/charts.git --path stable/redis --dest-server https://kubernetes.default.svc --dest-namespace default -p password=abc123
```
## Store Overrides In Git
The config management tool specific overrides can be specified in `.argocd-source.yaml` file stored in the source application
directory in the Git repository.
The `.argocd-source.yaml` file is used during manifest generation and overrides
application source fields, such as `kustomize`, `helm` etc.
Example:
```yaml
kustomize:
images:
- quay.io/argoprojlabs/argocd-e2e-container:0.2
```
The `.argocd-source` is trying to solve two following main use cases:
chore: Spelling (#5373) * spelling: across Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: anyway Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: assessment Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: attribute Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: crlf Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: cmux Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: committed Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: convenience Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: does-not Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: e.g. Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: fall back Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: fall back to Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: then ... falls back Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: formatted Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: github Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: gitlab Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: gitops Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: health checks Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: located Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: logging Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: oidc Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: openshift Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: os Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: powershell Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: preferred Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: redact Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: repo Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: similarly Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: staging Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: statefulset Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: stopped Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: superseded Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: synchronization Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: to Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: unified Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: verification Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: zookeeper Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2021-07-13 17:02:03 +00:00
- Provide the unified way to "override" application parameters in Git and enable the "write back" feature
for projects like [argocd-image-updater](https://github.com/argoproj-labs/argocd-image-updater).
- Support "discovering" applications in the Git repository by projects like [applicationset](https://github.com/argoproj/applicationset)
(see [git files generator](https://github.com/argoproj/argo-cd/blob/master/applicationset/examples/git-generator-files-discovery/git-generator-files.yaml))
You can also store parameter overrides in an application specific file, if you
are sourcing multiple applications from a single path in your repository.
The application specific file must be named `.argocd-source-<appname>.yaml`,
where `<appname>` is the name of the application the overrides are valid for.
When combined with the [apps-in-any-namespace](../operator-manual/app-any-namespace.md)
feature, filename is expected to include the namespace name as a prefix, i.e.
`.argocd-source-<namespace>_<appname>.yaml`.
If there exists a non-application specific `.argocd-source.yaml`, parameters
included in that file will be merged first, and then the application specific
parameters are merged, which can also contain overrides to the parameters
stored in the non-application specific file.