Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
helm: circleci/helm@3.1.0
Use helm
elements in your existing workflows and jobs.
Demonstrate installing a helm chart on a Kubernetes cluster, with helm 3.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
version: '2.1'
orbs:
aws-eks: circleci/aws-eks@2.1.2
helm: circleci/helm@1.0
jobs:
delete_helm_release:
executor: aws-eks/python
parameters:
cluster-name:
description: Cluster name
type: string
steps:
- aws-eks/update-kubeconfig-with-authenticator:
cluster-name: << parameters.cluster-name >>
- helm/delete_helm_release:
helm_version: v3.2.4
release_name: grafana-release
timeout: 600s
install_helm_chart:
executor: aws-eks/python
parameters:
cluster-name:
description: Cluster name
type: string
steps:
- aws-eks/update-kubeconfig-with-authenticator:
cluster-name: << parameters.cluster-name >>
- helm/install_helm_chart:
chart: stable/grafana
helm_version: v3.2.4
release_name: grafana-release
workflows:
deployment:
jobs:
- aws-eks/create-cluster:
cluster-name: test-cluster
- install_helm_chart:
cluster-name: test-cluster
requires:
- aws-eks/create-cluster
- delete_helm_release:
cluster-name: test-cluster
requires:
- install_helm_chart
- aws-eks/delete-cluster:
cluster-name: test-cluster
requires:
- delete_helm_release
wait: true
Deletes a helm release. Requirements: helm should be installed on the cluster and kubeconfig should be configured to connect to the cluster.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
helm_version | the helm client version to install. e.g. v3.0.0. | No | v3.8.2 | string |
keep_history | Effective for helm 3 commands only.
Retains release history.
| No | false | boolean |
namespace | The kubernetes namespace that should be used.
| No | '' | string |
no_output_timeout | Elapsed time that the helm command can run on CircleCI without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
| No | 30m | string |
purge | Effective for helm 2 commands only (purging is the default in helm 3)
Whether to remove the release from the store and make its name free for
later use
| No | false | boolean |
release_name | Specify the release to be deleted.
| Yes | - | string |
tiller_namespace | Specify the namespace of Tiller
| No | '' | string |
timeout | Specify a timeout value that will be passed as a --timeout argument
to the helm command. For helm 3, the unit of the duration must
be specified e.g. '300s'.
| No | '' | string |
tls | Enable TLS for the request
| No | false | boolean |
tls_ca_cert | Path to TLS CA certificate file
| No | '' | string |
tls_cert | Path to TLS certificate file
| No | '' | string |
tls_hostname | The server name used to verify the hostname on the returned
certificates from the server
| No | '' | string |
tls_key | Path to TLS key file
| No | '' | string |
tls_verify | Enable TLS for request and verify remote
| No | false | boolean |
Installs a helm chart. Requirements: helm should be installed on the cluster and kubeconfig should be configured to connect to the cluster.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
add_repo | The url for the helm chart repository used as part of helm repo add
command
| Yes | - | string |
chart | Specify for installation a chart reference (e.g. stable/mariadb),
or a path to a packaged chart (e.g. ./nginx-1.2.3.tgz),
or a path to an unpacked chart directory (e.g. ./nginx)
or an absolute URL (e.g. https://example.com/charts/nginx-1.2.3.tgz)
| Yes | - | string |
create_namespace | This parameter creates the kubernetes namespace if the one provided does not exist.
| No | false | boolean |
debug | Enable debug mode by adding --debug to helm command. Defaults to false.
| No | false | boolean |
helm_version | the helm client version to install. e.g. v3.0.0 | No | v3.8.2 | string |
namespace | The kubernetes namespace that should be used.
| No | '' | string |
no_output_timeout | Elapsed time that the helm command can run on CircleCI without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
| No | 30m | string |
release_name | Specify a name for the release.
| No | '' | string |
update_repositories | Choose to update repositories by running helm repo update.
| No | true | boolean |
values_to_override | Override values in a chart using the --set flag of the helm install
command. Format: key1=val1,key2=val2
| No | '' | string |
wait | Whether to wait for the installation or upgrade to be complete
| No | false | boolean |
wait_for_jobs | Whether to wait for all jobs associated with deployment to be complete before marking the release as successful.
| No | false | boolean |
Install the helm client. Defaults to the latest version of Helm 3. You can specify a specific version e.g v3.0.0. Requirements: curl
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
retries | The amount of retries when downloading the helm client, in case it fails. | No | 2 | integer |
version | the helm client version to install. e.g. v3.8.0 | No | v3.8.2 | string |
Installs a helm plugin. Requirements: helm should be installed on the cluster
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
helm_plugin_url | absolute URL to helm plugin to install
(e.g. https://example.com/helm-plugin/helm-plugin-1.2.3.tgz)
| Yes | - | string |
helm_version | the helm client version to install. e.g. v3.0.0 | No | v3.8.2 | string |
no_output_timeout | Elapsed time that the helm command can run on CircleCI without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
| No | 30m | string |
Upgrades an existing helm chart Requirements: helm should be installed on the cluster and kubeconfig should be configured to connect to the cluster.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
add_repo | The url for the helm chart repository used as part of helm repo add
command
| No | '' | string |
atomic | if set, upgrade process rolls back changes made in case of failed upgrade.
The --wait flag will be set automatically if --atomic is used
| No | false | boolean |
chart | Specify for upgrade a chart reference (e.g. stable/mariadb),
or a path to a packaged chart (e.g. ./nginx-1.2.3.tgz),
or a path to an unpacked chart directory (e.g. ./nginx)
or an absolute URL (e.g. https://example.com/charts/nginx-1.2.3.tgz)
| No | '' | string |
create_namespace | This parameter creates the kubernetes namespace if the one provided does not exist.
| No | false | boolean |
debug | Enable debug mode by adding --debug to helm command. Defaults to false.
| No | false | boolean |
devel | Use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.
| No | '' | string |
dry_run | simulate an upgrade
| No | false | boolean |
force | Use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.
| No | false | boolean |
helm_version | the helm client version to install. e.g. v3.0.0 | No | v3.8.2 | string |
history_max | limit the maximum number of revisions saved per release. Use 0 for no limit (default 10)
| No | 10 | integer |
namespace | The kubernetes namespace that should be used.
| No | '' | string |
no_hooks | This skips running hooks for the command
| No | false | boolean |
no_output_timeout | Elapsed time that the helm command can run on CircleCI without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
| No | 30m | string |
recreate_pods | performs pods restart for the resource if applicable
| No | false | boolean |
release_name | Specify a name for the release.
| No | '' | string |
reset_values | when upgrading, reset the values to the ones built into the chart
| No | false | boolean |
reuse_values | when upgrading, reuse the last release's values and merge in any overrides from the command line via --set and -f. If '--reset_values' is specified, this is ignored.
| No | false | boolean |
timeout | If timeout is reached, the release will be marked as FAILED.
| No | '' | string |
values | specify values in a YAML file or a URL
| No | '' | string |
values_to_override | Override values in a chart using the --set flag of the helm upgrade
command. Format: key1=val1,key2=val2
| No | '' | string |
version | specify the exact chart version to use. If this is not specified, the latest version is used
| No | '' | string |
wait | Whether to wait for the installation to be complete.
| No | false | boolean |
wait_for_jobs | Whether to wait for all jobs associated with deployment to be complete before marking the release as successful.
| No | false | boolean |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: |
An orb for working with helm for Kubernetes deployments. Currently supports helm3 versions.
display:
home_url: https://helm.sh/
source_url: https://github.com/CircleCI-Public/helm-orb
commands:
delete_helm_release:
description: |
Deletes a helm release.
Requirements: helm should be installed on the cluster
and kubeconfig should be configured to connect to the cluster.
parameters:
helm_version:
default: v3.8.2
description: the helm client version to install. e.g. v3.0.0.
type: string
keep_history:
default: false
description: |
Effective for helm 3 commands only.
Retains release history.
type: boolean
namespace:
default: ""
description: |
The kubernetes namespace that should be used.
type: string
no_output_timeout:
default: 30m
description: |
Elapsed time that the helm command can run on CircleCI without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
type: string
purge:
default: false
description: |
Effective for helm 2 commands only (purging is the default in helm 3)
Whether to remove the release from the store and make its name free for
later use
type: boolean
release_name:
description: |
Specify the release to be deleted.
type: string
tiller_namespace:
default: ""
description: |
Specify the namespace of Tiller
type: string
timeout:
default: ""
description: |
Specify a timeout value that will be passed as a --timeout argument
to the helm command. For helm 3, the unit of the duration must
be specified e.g. '300s'.
type: string
tls:
default: false
description: |
Enable TLS for the request
type: boolean
tls_ca_cert:
default: ""
description: |
Path to TLS CA certificate file
type: string
tls_cert:
default: ""
description: |
Path to TLS certificate file
type: string
tls_hostname:
default: ""
description: |
The server name used to verify the hostname on the returned
certificates from the server
type: string
tls_key:
default: ""
description: |
Path to TLS key file
type: string
tls_verify:
default: false
description: |
Enable TLS for request and verify remote
type: boolean
steps:
- install_helm_client:
version: << parameters.helm_version >>
- run:
command: |-
#!/bin/bash
HELM_STR_TIMEOUT="$(echo "${HELM_STR_TIMEOUT}" | circleci env subst)"
HELM_STR_NAMESPACE="$(echo "${HELM_STR_NAMESPACE}" | circleci env subst)"
HELM_STR_TLS_CA_CERT="$(echo "${HELM_STR_TLS_CA_CERT}" | circleci env subst)"
HELM_STR_TLS_CERT="$(echo "${HELM_STR_TLS_CERT}" | circleci env subst)"
HELM_STR_TLS_HOSTNAME="$(echo "${HELM_STR_TLS_HOSTNAME}" | circleci env subst)"
HELM_STR_TLS_KEY="$(echo "${HELM_STR_TLS_KEY}" | circleci env subst)"
HELM_STR_RELEASE_NAME="$(echo "${HELM_STR_RELEASE_NAME}" | circleci env subst)"
HELM_STR_TILLER_NAMESPACE="$(echo "${HELM_STR_TILLER_NAMESPACE}" | circleci env subst)"
set -x
if [ -n "${HELM_STR_TIMEOUT}" ]; then
set -- "$@" --timeout="${HELM_STR_TIMEOUT}"
fi
if [ -n "${HELM_STR_NAMESPACE}" ]; then
set -- "$@" --namespace="${HELM_STR_NAMESPACE}"
fi
if [ "${HELM_BOOL_TLS}" -eq 1 ]; then
set -- "$@" --tls
fi
if [ -n "${HELM_STR_TLS_CA_CERT}" ]; then
set -- "$@" --tls-ca-cert="${HELM_STR_TLS_CA_CERT}"
fi
if [ -n "${HELM_STR_TLS_CERT}" ]; then
set -- "$@" --tls-cert="${HELM_STR_TLS_CERT}"
fi
if [ -n "${HELM_STR_TLS_HOSTNAME}" ]; then
set -- "$@" --tls-hostname="${HELM_STR_TLS_HOSTNAME}"
fi
if [ -n "${HELM_STR_TLS_KEY}" ]; then
set -- "$@" --tls-key="${HELM_STR_TLS_KEY}"
fi
if [ "${HELM_BOOL_TLS_VERIFY}" -eq 1 ]; then
set -- "$@" --tls-verify
fi
if [ -n "${HELM_STR_TILLER_NAMESPACE}" ]; then
set -- "$@" --tiller-namespace "${HELM_STR_TILLER_NAMESPACE}"
fi
VERSION_2_MATCH="$(helm version --short -c | grep 'Client: v2' || true)"
if [ -n "${VERSION_2_MATCH}" ]; then
if [ "${HELM_BOOL_PURGE}" -eq 1 ]; then
set -- "$@" --purge
fi
else
if [ "${HELM_BOOL_KEEP_HISTORY}" -eq 1 ]; then
set -- "$@" --keep-history
fi
fi
helm delete "$@" "${HELM_STR_RELEASE_NAME}"
set +x
environment:
HELM_BOOL_KEEP_HISTORY: << parameters.keep_history >>
HELM_BOOL_PURGE: << parameters.purge >>
HELM_BOOL_TLS: << parameters.tls >>
HELM_BOOL_TLS_VERIFY: << parameters.tls_verify >>
HELM_STR_NAMESPACE: << parameters.namespace >>
HELM_STR_RELEASE_NAME: << parameters.release_name >>
HELM_STR_TILLER_NAMESPACE: << parameters.tiller_namespace >>
HELM_STR_TIMEOUT: << parameters.timeout >>
HELM_STR_TLS_CA_CERT: << parameters.tls_ca_cert >>
HELM_STR_TLS_CERT: << parameters.tls_cert >>
HELM_STR_TLS_HOSTNAME: << parameters.tls_hostname >>
HELM_STR_TLS_KEY: << parameters.tls_key >>
name: Delete helm release
no_output_timeout: << parameters.no_output_timeout >>
install_helm_chart:
description: |
Installs a helm chart.
Requirements: helm should be installed on the cluster
and kubeconfig should be configured to connect to the cluster.
parameters:
add_repo:
description: |
The url for the helm chart repository used as part of helm repo add
command
type: string
chart:
description: |
Specify for installation a chart reference (e.g. stable/mariadb),
or a path to a packaged chart (e.g. ./nginx-1.2.3.tgz),
or a path to an unpacked chart directory (e.g. ./nginx)
or an absolute URL (e.g. https://example.com/charts/nginx-1.2.3.tgz)
type: string
create_namespace:
default: false
description: |
This parameter creates the kubernetes namespace if the one provided does not exist.
type: boolean
debug:
default: false
description: |
Enable debug mode by adding --debug to helm command. Defaults to false.
type: boolean
helm_version:
default: v3.8.2
description: the helm client version to install. e.g. v3.0.0
type: string
namespace:
default: ""
description: |
The kubernetes namespace that should be used.
type: string
no_output_timeout:
default: 30m
description: |
Elapsed time that the helm command can run on CircleCI without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
type: string
release_name:
default: ""
description: |
Specify a name for the release.
type: string
update_repositories:
default: true
description: |
Choose to update repositories by running helm repo update.
type: boolean
values_to_override:
default: ""
description: |
Override values in a chart using the --set flag of the helm install
command. Format: key1=val1,key2=val2
type: string
wait:
default: false
description: |
Whether to wait for the installation or upgrade to be complete
type: boolean
wait_for_jobs:
default: false
description: |
Whether to wait for all jobs associated with deployment to be complete before marking the release as successful.
type: boolean
steps:
- install_helm_client:
version: << parameters.helm_version >>
- when:
condition: << parameters.update_repositories >>
steps:
- run:
command: |
helm repo add <<parameters.release_name>> <<parameters.add_repo>> && \
helm repo update
name: Update repositories
- run:
command: |-
#!/bin/bash
HELM_STR_VALUES_TO_OVERRIDE="$(echo "${HELM_STR_VALUES_TO_OVERRIDE}" | circleci env subst)"
HELM_STR_NAMESPACE="$(echo "${HELM_STR_NAMESPACE}" | circleci env subst)"
HELM_STR_RELEASE_NAME="$(echo "${HELM_STR_RELEASE_NAME}" | circleci env subst)"
HELM_STR_CHART="$(echo "${HELM_STR_CHART}" | circleci env subst)"
set -x
if [ -n "${HELM_STR_VALUES_TO_OVERRIDE}" ]; then
set -- "$@" --set "${HELM_STR_VALUES_TO_OVERRIDE}"
fi
if [ "${HELM_BOOL_WAIT_FOR_JOBS}" -eq 1 ]; then
set -- "$@" --wait-for-jobs
fi
if [ -n "${HELM_STR_NAMESPACE}" ]; then
if [ "${HELM_BOOL_CREATE_NAMESPACE}" -eq "1" ]; then
set -- "$@" --create-namespace --namespace="${HELM_STR_NAMESPACE}"
else
set -- "$@" --namespace="${HELM_STR_NAMESPACE}"
fi
fi
if [ "${HELM_BOOL_WAIT}" -eq 1 ]; then
set -- "$@" --wait
fi
if [ "${HELM_BOOL_DEBUG}" -eq 1 ]; then
set -- "$@" --debug
fi
if [ -n "${HELM_STR_RELEASE_NAME}" ]; then
helm install "${HELM_STR_RELEASE_NAME}" "${HELM_STR_CHART}" "$@"
else
set -- "$@" --generate-name
helm install "${HELM_STR_CHART}" "$@"
fi
set +x
environment:
HELM_BOOL_CREATE_NAMESPACE: << parameters.create_namespace >>
HELM_BOOL_DEBUG: << parameters.debug >>
HELM_BOOL_WAIT: << parameters.wait >>
HELM_BOOL_WAIT_FOR_JOBS: << parameters.wait_for_jobs >>
HELM_STR_CHART: << parameters.chart >>
HELM_STR_NAMESPACE: << parameters.namespace >>
HELM_STR_RELEASE_NAME: << parameters.release_name >>
HELM_STR_VALUES_TO_OVERRIDE: << parameters.values_to_override >>
name: Install chart
no_output_timeout: << parameters.no_output_timeout >>
install_helm_client:
description: |
Install the helm client.
Defaults to the latest version of Helm 3. You can specify a specific version e.g v3.0.0.
Requirements: curl
parameters:
retries:
default: 2
description: The amount of retries when downloading the helm client, in case it fails.
type: integer
version:
default: v3.8.2
description: the helm client version to install. e.g. v3.8.0
type: string
steps:
- run:
command: "#!/bin/bash\nHELM_STR_VERSION=\"$(echo \"${HELM_STR_VERSION}\" | circleci env subst)\"\n\nset -x\nif command -v helm &> /dev/null; then\n echo \"helm is already installed\"\n exit 0\nfi\n\nif [ -n \"${HELM_STR_VERSION}\" ]; then\n set -- \"$@\" --version \"${HELM_STR_VERSION}\"\nfi\n\nINSTALL_SCRIPT=\"https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3\"\n\nsuccess_helm_download=false\nretry_count=0\nwhile [ \"$retry_count\" -lt \"$HELM_RETRIES\" ]; do\n \n if curl -sSf \"${INSTALL_SCRIPT}\" -o get_helm.sh; then\n echo \"Script downloaded succesfully\"\n success_helm_download=true\n break\n else\n echo \"Error downloading. Retying...\"\n retry_count=$((retry_count + 1))\n sleep 5\n fi\ndone\nif [ \"$success_helm_download\" = false ]; then\n echo \"Max retries reached\"\n exit 1\nfi\nchmod 700 get_helm.sh\n./get_helm.sh \"$@\"\n\nrm -rf get_helm.sh\nset +x\n"
environment:
HELM_RETRIES: <<parameters.retries>>
HELM_STR_VERSION: << parameters.version >>
name: Install and init the helm client (if necessary)
install_helm_plugin:
description: |
Installs a helm plugin.
Requirements: helm should be installed on the cluster
parameters:
helm_plugin_url:
description: |
absolute URL to helm plugin to install
(e.g. https://example.com/helm-plugin/helm-plugin-1.2.3.tgz)
type: string
helm_version:
default: v3.8.2
description: the helm client version to install. e.g. v3.0.0
type: string
no_output_timeout:
default: 30m
description: |
Elapsed time that the helm command can run on CircleCI without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
type: string
steps:
- install_helm_client:
version: << parameters.helm_version >>
- run:
command: |
#!/bin/bash
HELM_STR_PLUGIN_URL="$(echo "${HELM_STR_PLUGIN_URL}" | circleci env subst)"
STATUS="$(helm plugin install "${HELM_STR_PLUGIN_URL}")"
if echo "${STATUS}" | grep "Installed plugin:"; then
echo "Installation successful"
exit 0
else
echo "Installation failed. Please check the Helm plugin URL"
exit 1
fi
environment:
HELM_STR_PLUGIN_URL: << parameters.helm_plugin_url >>
name: Install helm plugin
no_output_timeout: << parameters.no_output_timeout >>
upgrade_helm_chart:
description: |
Upgrades an existing helm chart
Requirements: helm should be installed on the cluster
and kubeconfig should be configured to connect to the cluster.
parameters:
add_repo:
default: ""
description: |
The url for the helm chart repository used as part of helm repo add
command
type: string
atomic:
default: false
description: |
if set, upgrade process rolls back changes made in case of failed upgrade.
The --wait flag will be set automatically if --atomic is used
type: boolean
chart:
default: ""
description: |
Specify for upgrade a chart reference (e.g. stable/mariadb),
or a path to a packaged chart (e.g. ./nginx-1.2.3.tgz),
or a path to an unpacked chart directory (e.g. ./nginx)
or an absolute URL (e.g. https://example.com/charts/nginx-1.2.3.tgz)
type: string
create_namespace:
default: false
description: |
This parameter creates the kubernetes namespace if the one provided does not exist.
type: boolean
debug:
default: false
description: |
Enable debug mode by adding --debug to helm command. Defaults to false.
type: boolean
devel:
default: ""
description: |
Use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.
type: string
dry_run:
default: false
description: |
simulate an upgrade
type: boolean
force:
default: false
description: |
Use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.
type: boolean
helm_version:
default: v3.8.2
description: the helm client version to install. e.g. v3.0.0
type: string
history_max:
default: 10
description: |
limit the maximum number of revisions saved per release. Use 0 for no limit (default 10)
type: integer
namespace:
default: ""
description: |
The kubernetes namespace that should be used.
type: string
no_hooks:
default: false
description: |
This skips running hooks for the command
type: boolean
no_output_timeout:
default: 30m
description: |
Elapsed time that the helm command can run on CircleCI without output.
The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”
type: string
recreate_pods:
default: false
description: |
performs pods restart for the resource if applicable
type: boolean
release_name:
default: ""
description: |
Specify a name for the release.
type: string
reset_values:
default: false
description: |
when upgrading, reset the values to the ones built into the chart
type: boolean
reuse_values:
default: false
description: |
when upgrading, reuse the last release's values and merge in any overrides from the command line via --set and -f. If '--reset_values' is specified, this is ignored.
type: boolean
timeout:
default: ""
description: |
If timeout is reached, the release will be marked as FAILED.
type: string
values:
default: ""
description: |
specify values in a YAML file or a URL
type: string
values_to_override:
default: ""
description: |
Override values in a chart using the --set flag of the helm upgrade
command. Format: key1=val1,key2=val2
type: string
version:
default: ""
description: |
specify the exact chart version to use. If this is not specified, the latest version is used
type: string
wait:
default: false
description: |
Whether to wait for the installation to be complete.
type: boolean
wait_for_jobs:
default: false
description: |
Whether to wait for all jobs associated with deployment to be complete before marking the release as successful.
type: boolean
steps:
- install_helm_client:
version: << parameters.helm_version >>
- run:
command: |-
#!/bin/bash
HELM_STR_TIMEOUT="$(echo "${HELM_STR_TIMEOUT}" | circleci env subst)"
HELM_STR_NAMESPACE="$(echo "${HELM_STR_NAMESPACE}" | circleci env subst)"
HELM_STR_DEVEL="$(echo "${HELM_STR_DEVEL}" | circleci env subst)"
HELM_STR_VALUES="$(echo "${HELM_STR_VALUES}" | circleci env subst)"
HELM_STR_VERSION="$(echo "${HELM_STR_VERSION}" | circleci env subst)"
HELM_STR_VALUES_TO_OVERRIDE="$(echo "${HELM_STR_VALUES_TO_OVERRIDE}" | circleci env subst)"
HELM_STR_CHART="$(echo "${HELM_STR_CHART}" | circleci env subst)"
HELM_STR_RELEASE_NAME="$(echo "${HELM_STR_RELEASE_NAME}" | circleci env subst)"
HELM_STR_ADD_REPO="$(echo "${HELM_STR_ADD_REPO}" | circleci env subst)"
set -x
if [ -n "${HELM_STR_NAMESPACE}" ]; then
if [ "${HELM_BOOL_CREATE_NAMESPACE}" -eq "1" ]; then
set -- "$@" --create-namespace --namespace="${HELM_STR_NAMESPACE}"
else
set -- "$@" --namespace="${HELM_STR_NAMESPACE}"
fi
fi
if [ -n "${HELM_STR_TIMEOUT}" ]; then
set -- "$@" --timeout "${HELM_STR_TIMEOUT}"
fi
if [ "${HELM_BOOL_NO_HOOKS}" = "1" ]; then
set -- "$@" --no-hooks
fi
if [ "${HELM_BOOL_RECREATE_PODS}" -eq 1 ]; then
set -- "$@" --recreate-pods
fi
if [ "${HELM_BOOL_ATOMIC}" -eq 1 ]; then
set -- "$@" --atomic
fi
if [ "${HELM_BOOL_WAIT}" -eq 1 ]; then
set -- "$@" --wait
fi
if [ -n "${HELM_STR_DEVEL}" ]; then
set -- "$@" --devel "${HELM_STR_DEVEL}"
fi
if [ "${HELM_BOOL_DRY_RUN}" -eq 1 ]; then
set -- "$@" --dry-run
fi
if [ "${HELM_BOOL_RESET_VALUES}" -eq 1 ]; then
set -- "$@" --reset-values
fi
if [ "${HELM_BOOL_REUSE_VALUES}" -eq 1 ]; then
set -- "$@" --reuse-values
fi
if [ -n "${HELM_STR_VALUES}" ]; then
set -- "$@" --values "${HELM_STR_VALUES}"
fi
if [ -n "${HELM_STR_VALUES_TO_OVERRIDE}" ]; then
set -- "$@" --set "${HELM_STR_VALUES_TO_OVERRIDE}"
fi
if [ -n "${HELM_INT_HISTORY_MAX}" ]; then
set -- "$@" --history-max "${HELM_INT_HISTORY_MAX}"
fi
if [ -n "${HELM_STR_VERSION}" ]; then
set -- "$@" --version="${HELM_STR_VERSION}"
fi
if [ "${HELM_BOOL_WAIT_FOR_JOBS}" -eq 1 ]; then
set -- "$@" --wait-for-jobs
fi
if [ "${HELM_BOOL_FORCE}" -eq 1 ]; then
set -- "$@" --force
fi
if [ "${HELM_BOOL_DEBUG}" -eq 1 ]; then
set -- "$@" --debug
fi
if [ -n "${HELM_STR_ADD_REPO}" ]; then
helm repo add "${HELM_STR_RELEASE_NAME}" "${HELM_STR_ADD_REPO}"
helm repo update
fi
helm upgrade --install "${HELM_STR_RELEASE_NAME}" "${HELM_STR_CHART}" "$@"
set +x
environment:
HELM_BOOL_ATOMIC: << parameters.atomic >>
HELM_BOOL_CREATE_NAMESPACE: << parameters.create_namespace >>
HELM_BOOL_DEBUG: << parameters.debug >>
HELM_BOOL_DRY_RUN: << parameters.dry_run >>
HELM_BOOL_FORCE: << parameters.force >>
HELM_BOOL_NO_HOOKS: << parameters.no_hooks >>
HELM_BOOL_RECREATE_PODS: << parameters.recreate_pods >>
HELM_BOOL_RESET_VALUES: << parameters.reset_values >>
HELM_BOOL_REUSE_VALUES: << parameters.reuse_values >>
HELM_BOOL_WAIT: << parameters.wait >>
HELM_BOOL_WAIT_FOR_JOBS: << parameters.wait_for_jobs >>
HELM_INT_HISTORY_MAX: << parameters.history_max >>
HELM_STR_ADD_REPO: << parameters.add_repo >>
HELM_STR_CHART: << parameters.chart >>
HELM_STR_DEVEL: << parameters.devel >>
HELM_STR_NAMESPACE: << parameters.namespace >>
HELM_STR_RELEASE_NAME: << parameters.release_name >>
HELM_STR_TIMEOUT: << parameters.timeout >>
HELM_STR_VALUES: << parameters.values >>
HELM_STR_VALUES_TO_OVERRIDE: << parameters.values_to_override >>
HELM_STR_VERSION: << parameters.version >>
name: Upgrade, update, or install chart
no_output_timeout: << parameters.no_output_timeout >>
examples:
install_helm_chart_with_helm3:
description: |
Demonstrate installing a helm chart on a Kubernetes cluster, with
helm 3.
usage:
version: "2.1"
orbs:
aws-eks: circleci/aws-eks@2.1.2
helm: circleci/helm@1.0
jobs:
delete_helm_release:
executor: aws-eks/python
parameters:
cluster-name:
description: Cluster name
type: string
steps:
- aws-eks/update-kubeconfig-with-authenticator:
cluster-name: << parameters.cluster-name >>
- helm/delete_helm_release:
helm_version: v3.2.4
release_name: grafana-release
timeout: 600s
install_helm_chart:
executor: aws-eks/python
parameters:
cluster-name:
description: Cluster name
type: string
steps:
- aws-eks/update-kubeconfig-with-authenticator:
cluster-name: << parameters.cluster-name >>
- helm/install_helm_chart:
chart: stable/grafana
helm_version: v3.2.4
release_name: grafana-release
workflows:
deployment:
jobs:
- aws-eks/create-cluster:
cluster-name: test-cluster
- install_helm_chart:
cluster-name: test-cluster
requires:
- aws-eks/create-cluster
- delete_helm_release:
cluster-name: test-cluster
requires:
- install_helm_chart
- aws-eks/delete-cluster:
cluster-name: test-cluster
requires:
- delete_helm_release
wait: true