github.com/argoproj/argo-cd@v1.8.7/docs/user-guide/helm.md (about) 1 # Helm 2 3 ## Values Files 4 5 Helm has the ability to use a different, or even multiple "values.yaml" files to derive its 6 parameters from. Alternate or multiple values file(s), can be specified using the `--values` 7 flag. The flag can be repeated to support multiple values files: 8 9 ```bash 10 argocd app set helm-guestbook --values values-production.yaml 11 ``` 12 !!! note 13 Values files must be in the same git repository as the Helm chart. The files can be in a different 14 location in which case it can be accessed using a relative path relative to the root directory of 15 the Helm chart. 16 17 ## Helm Parameters 18 19 Helm has the ability to set parameter values, which override any values in 20 a `values.yaml`. For example, `service.type` is a common parameter which is exposed in a Helm chart: 21 22 ```bash 23 helm template . --set service.type=LoadBalancer 24 ``` 25 26 Similarly, Argo CD can override values in the `values.yaml` parameters using `argo app set` command, 27 in the form of `-p PARAM=VALUE`. For example: 28 29 ```bash 30 argocd app set helm-guestbook -p service.type=LoadBalancer 31 ``` 32 33 ## Helm Release Name 34 35 By default, the Helm release name is equal to the Application name to which it belongs. Sometimes, especially on a centralised ArgoCD, 36 you may want to override that name, and it is possible with the `release-name` flag on the cli: 37 38 ```bash 39 argocd app set helm-guestbook --release-name myRelease 40 ``` 41 42 or using the releaseName for yaml: 43 44 ```yaml 45 source: 46 helm: 47 releaseName: myRelease 48 ``` 49 50 !!! warning "Important notice on overriding the release name" 51 Please note that overriding the Helm release name might cause problems when the chart you are deploying is using the `app.kubernetes.io/instance` label. ArgoCD injects this label with the value of the Application name for tracking purposes. So when overriding the release name, the Application name will stop being equal to the release name. Because ArgoCD will overwrite the label with the Application name it might cause some selectors on the resources to stop working. In order to avoid this we can configure ArgoCD to use another label for tracking in the [ArgoCD configmap argocd-cm.yaml](../operator-manual/argocd-cm.yaml) - check the lines describing `application.instanceLabelKey`. 52 53 ## Helm Hooks 54 55 > v1.3 or later 56 57 Helm hooks are similar to [Argo CD hooks](resource_hooks.md). In Helm, a hook 58 is any normal Kubernetes resource annotated with the `helm.sh/hook` annotation. 59 60 Argo CD supports many (most?) Helm hooks by mapping the Helm annotations onto Argo CD's own hook annotations: 61 62 | Helm Annotation | Notes | 63 |---|---| 64 | `helm.sh/hook: crd-install` | Supported as equivalent to `argocd.argoproj.io/hook: PreSync`. | 65 | `helm.sh/hook: pre-delete` | Not supported. In Helm stable there are 3 cases used to clean up CRDs and 3 to clean-up jobs. | 66 | `helm.sh/hook: pre-rollback` | Not supported. Never used in Helm stable. | 67 | `helm.sh/hook: pre-install` | Supported as equivalent to `argocd.argoproj.io/hook: PreSync`. | 68 | `helm.sh/hook: pre-upgrade` | Supported as equivalent to `argocd.argoproj.io/hook: PreSync`. | 69 | `helm.sh/hook: post-upgrade` | Supported as equivalent to `argocd.argoproj.io/hook: PostSync`. | 70 | `helm.sh/hook: post-install` | Supported as equivalent to `argocd.argoproj.io/hook: PostSync`. | 71 | `helm.sh/hook: post-delete` | Not supported. Never used in Helm stable. | 72 | `helm.sh/hook: post-rollback` | Not supported. Never used in Helm stable. | 73 | `helm.sh/hook: test-success` | Not supported. No equivalent in Argo CD. | 74 | `helm.sh/hook: test-failure` | Not supported. No equivalent in Argo CD. | 75 | `helm.sh/hook-delete-policy` | Supported. See also `argocd.argoproj.io/hook-delete-policy`). | 76 | `helm.sh/hook-delete-timeout` | No supported. Never used in Helm stable | 77 | `helm.sh/hook-weight` | Supported as equivalent to `argocd.argoproj.io/sync-wave`. | 78 79 Unsupported hooks are ignored. In Argo CD, hooks are created by using `kubectl apply`, rather than `kubectl create`. This means that if the hook is named and already exists, it will not change unless you have annotated it with `before-hook-creation`. 80 81 !!! warning "'install' vs 'upgrade' vs 'sync'" 82 Argo CD cannot know if it is running a first-time "install" or an "upgrade" - every operation is a "sync'. This means that, by default, apps that have `pre-install` and `pre-upgrade` will have those hooks run at the same time. 83 84 ### Hook Tips 85 86 * Make your hook idempotent. 87 * Annotate `crd-install` with `hook-weight: "-2"` to make sure it runs to success before any install or upgrade hooks. 88 * Annotate `pre-install` and `post-install` with `hook-weight: "-1"`. This will make sure it runs to success before any upgrade hooks. 89 * Annotate `pre-upgrade` and `post-upgrade` with `hook-delete-policy: before-hook-creation` to make sure it runs on every sync. 90 91 Read more about [Argo hooks](resource_hooks.md) and [Helm hooks](https://github.com/helm/helm/blob/dev-v2/docs/charts_hooks.md). 92 93 ## Random Data 94 95 Helm templating has the ability to generate random data during chart rendering via the 96 `randAlphaNum` function. Many helm charts from the [charts repository](https://github.com/helm/charts) 97 make use of this feature. For example, the following is the secret for the 98 [redis helm chart](https://github.com/helm/charts/blob/master/stable/redis/templates/secret.yaml): 99 100 ```yaml 101 data: 102 {{- if .Values.password }} 103 redis-password: {{ .Values.password | b64enc | quote }} 104 {{- else }} 105 redis-password: {{ randAlphaNum 10 | b64enc | quote }} 106 {{- end }} 107 ``` 108 109 The Argo CD application controller periodically compares Git state against the live state, running 110 the `helm template <CHART>` command to generate the helm manifests. Because the random value is 111 regenerated every time the comparison is made, any application which makes use of the `randAlphaNum` 112 function will always be in an `OutOfSync` state. This can be mitigated by explicitly setting a 113 value, in the values.yaml such that the value is stable between each comparison. For example: 114 115 ```bash 116 argocd app set redis -p password=abc123 117 ``` 118 119 ## Build Environment 120 121 > v1.4 122 123 Helm apps have access to the [standard build environment](build-environment.md) via substitution as parameters. 124 125 E.g. via the CLI: 126 127 ```bash 128 argocd app create APPNAME \ 129 --helm-set-string 'app=${ARGOCD_APP_NAME}' 130 ``` 131 132 Or via declarative syntax: 133 134 ```yaml 135 spec: 136 source: 137 helm: 138 parameters: 139 - name: app 140 value: $ARGOCD_APP_NAME 141 ``` 142 143 ## Helm plugins 144 145 > v1.5 146 147 Argo CD is un-opinionated on what cloud provider you use and what kind of Helm plugins you are using, that's why there are no plugins delivered with the ArgoCD image. 148 149 But sometimes it happens you would like to use a custom plugin. One of the cases is that you would like to use Google Cloud Storage or Amazon S3 storage to save the Helm charts, for example: https://github.com/hayorov/helm-gcs where you can use `gs://` protocol for Helm chart repository access. 150 151 In order to do that you have to prepare your own ArgoCD image with installed plugins. 152 153 Example `Dockerfile`: 154 155 ``` 156 FROM argoproj/argocd:v1.5.7 157 158 USER root 159 RUN apt-get update && \ 160 apt-get install -y \ 161 curl && \ 162 apt-get clean && \ 163 rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 164 165 USER argocd 166 167 ARG GCS_PLUGIN_VERSION="0.3.5" 168 ARG GCS_PLUGIN_REPO="https://github.com/hayorov/helm-gcs.git" 169 170 RUN helm plugin install ${GCS_PLUGIN_REPO} --version ${GCS_PLUGIN_VERSION} 171 172 ENV HELM_PLUGINS="/home/argocd/.local/share/helm/plugins/" 173 ``` 174 175 You have to remember about `HELM_PLUGINS` environment property - this is required for plugins to work correctly. 176 177 After that you have to use your custom image for ArgoCD installation. 178 179 ## Helm Version 180 181 ArgoCD normally detects which version of Helm to use by looking at the `apiVersion` in Chart.yaml. 182 183 If needed, it is possible to specifically set the Helm version to template with by setting the `helm-version` flag on the cli (either v2 or v3): 184 185 ```bash 186 argocd app set helm-guestbook --helm-version v2 187 ``` 188 189 Or using declarative syntax: 190 191 ```yaml 192 spec: 193 source: 194 helm: 195 version: v2 196 ```