Commit Graph

875 Commits

Author SHA1 Message Date
Yusuke Kuoka 794ab9fc66
Fix lint and status not to fail with selector and needs (#1834)
Fixes #1830
2021-05-08 21:23:09 +09:00
Yusuke Kuoka 48bd5c0979 Update go.sum for successful build 2021-05-08 08:49:57 +00:00
Quan TRAN e39a0b3639
bump Go to 1.16.3 and cover helm 3.5.4 (#1825)
* bump go to 1.16.3

* add helm 3.5.4 to integration tests
2021-05-08 17:37:58 +09:00
katsew 58954109fb
fix kubeContext does not globally defaulting its value (#1829)
Ref #1810
2021-05-08 17:35:46 +09:00
Yusuke Kuoka cb7fa6bf63
Bump vals to 0.14.0 (#1832)
This release includes new `ref+tfstates3://` and `ref+tfstategs://` backends for reading terraform states stored in s3 and google cloud storage, and features a new aws-sdk-go that supports AWS SSO, and the fix to allow referencing a local tfstate file by the absolute path.

See https://github.com/variantdev/vals/releases/tag/v0.14.0 for all the changes.
2021-05-08 17:33:37 +09:00
Yusuke Kuoka 44fb68b7e0
Use the incubator chart repo instead of chartcenter (#1833)
As ChartCenter has been shut down.

Ref https://github.com/roboll/helmfile/pull/1829#issuecomment-833330609
2021-05-08 17:33:24 +09:00
Quan TRAN ded0f1049a
Fix filepath handling on Windows (#1754) 2021-05-02 09:22:25 +09:00
Yusuke Kuoka 08db073958
Fix broken selector and DAG calculation logic after --{include,skip}-needs addition with correct Release IDs (#1823)
#1772 broke `--selector` with `needs` in many ways.

The two biggest problems I've encountered were:

- duplicate releases even if you've provided a proper `selector` to deduplicate
- sync/deletion ordering broken when you have `needs`

For the first issue, we had to update `getSelectedReleases` function to also calculate the "selected releases and releases needed by the selected releases", and use that to calculate the DAG. That should have been done in #1772.

The latter started happening after I've fixed the first issue. The source of the issue was that `needs` turned out to be ambiguous in a few cases.

Previously, `needs: ["foo/bar"]` had two meanings. One for "needs release bar in kubecontext foo", another for "needs release bar in namespace foo".

Moreover, `needs: ["foo/bar/baz"]` had three meanings.

- `needs release baz in tiller namespace foo and namespace baz`
- `needs release baz in namespace bar in kubecontext foo`
- `needs release baz in tiller namespace bar in kubecontext foo`.

Especially, the first meaning doesn't make sense at all. Helm 2 solely use tillerNamespace for namespacing the release and Helm 3 uses namespace for that.

This fix sorts all the bugs and issues I've found so far around that, by changing the meanings of the above two examples as follows:

- `foo/bar` means `namespace=foo,name=bar` for Helm 3 and `tillerNamespace=foo,name=bar` for Helm 2
  - `needs release bar in kubecontext foo` is now `foo//bar`. Notice the extra `/` between `foo` and `bar`.
- `foo/bar/baz` means `kubecontext=foo,namespace=bar,name=baz` for Helm 3 and `kubecontext=foo,tillerNamespace=bar,name=baz` in Helm 2

Fixes #1818
2021-05-01 21:59:25 +09:00
Yusuke Kuoka de8644a504
Fix --selector results to correctly deduplicate releases (#1822)
Fixes #1818
2021-05-01 15:06:07 +09:00
katsew f28ad5af23
Fix defaulting and overriding kubeContext (#1814)
Ref #1810

* fix defaulting and overriding kubeContext

* make defaulting kubeContext side-effect free

* checkDuplicates should check releases with overriden values
2021-05-01 12:42:29 +09:00
dudicoco 77ee239db2
Lock helm plugin versions in Dockerfile (#1821) 2021-05-01 12:26:54 +09:00
Vladimir Avdoshka d9e15754b7
Add documentation about re-using the environment state from parent in sub-helmfile (#1808)
Ref #762

Co-authored-by: Vladimir Avdoshka <vavdoshka@kyriba.com>
Co-authored-by: Quan TRAN <itscaro@users.noreply.github.com>
2021-05-01 12:26:00 +09:00
Yusuke Kuoka dabd7ad99f
Fix repo sync to work on repos duplicated between helm v2 and v3 (#1816)
Fixes #1815
2021-04-30 09:27:23 +09:00
Yusuke Kuoka 204f78c8ff
Fix --set and --set-file flags are not passed to chartify (#1803)
Fixes #1681
Ref 286ed08a27
2021-04-24 22:27:53 +09:00
Yusuke Kuoka 59b91a45a0
Fix adhoc dependencies not working with remote chart (#1802)
Fixes #1680

Ref 8ff30374cb
2021-04-24 21:11:07 +09:00
Yusuke Kuoka 5a3bd7d649
Fix destory, delete, and test to work with chartify on local chart with dependencies that are not yet downloaded (#1801)
Fixes #1800
2021-04-24 20:50:16 +09:00
Yusuke Kuoka ce6a621414
Bump chartify to 0.8.3 to fix it not to break when two or more releases sharing the same chart and the namespace, but kubeContext (#1799)
Fixes #1695
2021-04-24 19:03:13 +09:00
Yusuke Kuoka 20f6c68108 Fix code format 2021-04-24 07:47:27 +00:00
astorath 3367822e89
feat: Move chartify logs to Debug (#1794)
Co-authored-by: Andrey Tuzhilin <andrey@zelf.co>
2021-04-24 16:06:21 +09:00
katsew 8702639510
fix: spec.KubeContext does not fallback to HelmDefaults.KubeContext (#1789)
* fix: spec.KubeContext does not fallback to HelmDefaults.KubeContext

Fixes #1782

* Add testcases to test without default kubecontext
2021-04-24 16:02:58 +09:00
katsew 41cbc25c35
fix: can't evaluate field KubeContext in type state.releaseTemplateDataRelease (#1797)
Fixes #1796
2021-04-24 15:28:20 +09:00
astorath 83189dbad3
Enable `helmfile-diff` to pass the output format to helm-diff (#1784)
* tests: fix vagrant test run

* feat: added an option to specify the different diff output format

* renamed diff-output to output

* renamed diff-output to output

Co-authored-by: Andrey Tuzhilin <andrey@zelf.co>
2021-04-24 08:07:24 +09:00
Yusuke Kuoka 28ade19419
Bump chartify to 0.8.2 (#1793)
* Bump chartify to 0.8.2

This version fixes charitfy not to fail when you used the combination of (1)helm 3 and (2)strategicMergePatches/jsonPatches/transformers etc that triggers chartify on (3)a chart that contains CRDs.

See https://github.com/roboll/helmfile/issues/1778#issuecomment-824451990 for details of the issue.

The chartify-side of this fix is 55b23f9e9d

Fixes #1778
2021-04-23 09:53:52 +09:00
Yujun Zhang 378ae4ad72
Fix typo (#1788) 2021-04-23 09:27:37 +09:00
Yusuke Kuoka 30e0356ad6
Bump chartify to 0.8.1 (#1787)
This version fixes that chartify not to fail when the target chart misses `templates` directory.
2021-04-23 09:16:59 +09:00
Yusuke Kuoka eabda4cf28
Fix delete on release of `uninstalling` status (#1786)
* Fix helmfile destroy/delete not deleting `uninstalling` release

Ref https://github.com/roboll/helmfile/issues/1750#issuecomment-823677950

* Cover helm3 in helmfile-destroy test
2021-04-21 09:39:14 +09:00
Yusuke Kuoka 5617b593c8
Add test for helmfile-destroy with selector (#1785)
* Add test for helmfile-destroy with selector

I was curious if destroy with a selector is working at all while reading https://github.com/roboll/helmfile/issues/1750#issuecomment-823521572. So I added this test for verification. From the test result, it is working, though.

* Add one more test case for destroying disabled but installed release
2021-04-21 09:07:08 +09:00
Yusuke Kuoka 5d43b30a7c
Add --{include,skip}-needs to various helmfile commands (#1772)
* Add --{include,skip}-needs to helmfile-sync and helmfile-apply

* Add --include-needs to helmfile-template

* Add TODO related to #1018

* Add a few new test files to cover new functionalities

* Update apply test to incorporate the change that the destroy and sync steps target affected releases only
2021-04-20 23:06:51 +09:00
K1Hyve d6db4b53e7
Added The Hyve to USERS.md (#1779) 2021-04-20 13:29:44 +09:00
Yusuke Kuoka 368dd13e16
Fix destroy not reversing the order of releases (#1777)
Fixes #1775
2021-04-20 13:27:45 +09:00
Yusuke Kuoka ae942c5288
Fix --skip-crds not working with chartify (#1774)
Follow-up for #1771
Ref #1770
Ref https://github.com/roboll/helmfile/pull/1771#issuecomment-817399338
2021-04-13 09:09:58 +09:00
Yusuke Kuoka a111e89b27
Add `--skip-crds` to `helmfile sync` and `helmfile apply` (#1771)
Resolves #1770
2021-04-11 10:38:23 +09:00
Yusuke Kuoka 589b26aaad
Fix some hook log not honoring log level (#1769)
Fixes #1742
2021-04-10 16:50:42 +09:00
Yusuke Kuoka 1d7608f42c Fix `helmfile repos` to not fail with `forceNamespace`
Fixes #1752
2021-04-10 16:26:40 +09:00
Yusuke Kuoka efad26641d Add documentation about adhoc chart dependencies 2021-04-10 16:09:27 +09:00
Yusuke Kuoka 81b04fcb8b Add support for adhoc dependency to local chart
Helmfile has been providing a feature called "adhoc chart dependency" that basially enabled you to add Chart.yaml `dependencies` entry adhocly without forking or modifying the chart.

It was missing the support for using a local chart as the adhoc dependency. This patch adds that.

Usage:

`releases[].dependencies[].chart` is enhanced to accept the fs path to the local chart:

```
releases:
- name: foo
  chart: ./path/to/foo
  dependencies:
  - chart: ./path/to/bar
```

Resolves #1762
2021-04-10 16:09:27 +09:00
Yusuke Kuoka 74cd2bc147
Enable helmfile-deps to limit helm-dep-up by selector (#1764)
Ref https://github.com/roboll/helmfile/issues/809#issuecomment-814423653

This is not what had been requested originally in #809 but anyway- This enables you to limit helm-dep-up run by helmfile-deps by selector. For example, `helmfile -l name=foo deps` should result in only the release named `foo` to be helm-dep-uped.
2021-04-09 09:49:57 +09:00
Yusuke Kuoka 2ff06a8abd
Fix chartify to take --include-crds into account (#1761)
Fixes #1760
2021-04-08 10:06:34 +09:00
Yusuke Kuoka d703e17239
Fix chartify not to fail on a chart with dependencies (#1759)
Manually verified to work by using the following example from @damoon (https://github.com/roboll/helmfile/issues/1655#issuecomment-801122431):

```
repositories:
  - name: prometheus-community
    url: https://prometheus-community.github.io/helm-charts
releases:
- name: metrics
  namespace: monitoring
  chart: prometheus-community/kube-prometheus-stack
  version: 13.13.0
  jsonPatches:
    - target:
        version: v1
        kind: Service
        name: metrics-kube-prometheus-st-kube-etcd
        namespace: kube-system
      patch:
        - op: replace
          path: /spec/ports/0/port
          value: "2381"
        - op: replace
          path: /spec/ports/0/targetPort
          value: "2381"
```

Before this fix:
```
$ helmfile template
(snip)
COMBINED OUTPUT:
  Error: found in Chart.yaml, but missing in charts/ directory: kube-state-metrics, prometheus-node-exporter, grafana
```

After this fix:

```
$ helmfile template | grep 2381
(snip)
Removing /tmp/chartify718204429/monitoring-metrics-f5479c8b8/kube-prometheus-stack/strategicmergepatches
Removing /tmp/chartify718204429/monitoring-metrics-f5479c8b8/kube-prometheus-stack/kustomization.yaml
Templating release=metrics, chart=/tmp/chartify718204429/monitoring-metrics-f5479c8b8/kube-prometheus-stack
    port: "2381"
    targetPort: "2381"
```

Fixes #1655

Ref 07c3054d66
2021-04-08 07:03:18 +09:00
Yusuke Kuoka 3bfcc1ea42
Add support for kustomize v4 (#1758)
We use kustomize in two places. One for turning kustomize into a chart, and another for patching manifests and the chart.

This fixes the former to work with kustomize v4.

Fixes #1688
2021-04-08 06:15:16 +09:00
Quan TRAN c65bdff62c
Respect release filter in lint and status (#1672)
Ref #1190
Fixes #1651

Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
2021-04-06 15:47:29 +09:00
Yusuke Kuoka f614e8b1bf
feat: Helmfile renders *.yaml.gotmpl in a K8s manifests/kustomization directory (#1745)
Related to #494

This feature is mostly a built-in alternative to the `incubator/raw` chart without external dependency and has
access to helmfile's own template functions and template data.

The expected use-case of this feature is to add arbitrary K8s resources to your deployment.

Unlike the original issue raised in #494 this doesn't enable you to add arbitary resources to a release. That's another story. But this would be a good foundation for that, too.
2021-04-06 14:22:34 +09:00
Philipp Hossner 85accf7330
Add helm-secrets-encrypted values template file (#1701)
Secret files ending with .gotmpl are now also rendered as a gotemplate.

```
releases:
- name: myapp
  secrets:
  - secrets.yaml.gotmpl
```

Note that currently, .gotmpl files must be valid YAML files as well.

The expected use-case of this feature is to compose a YAML array from values and encrypted secrets.

Without this feature, you would have tried to do something like the below, which didn't work.

**Example (doesn't work!)**

`values.yaml.gotmpl`:

```
environment:
  -   name: MY_EXTERNAL_IP
      value: |
          {{ exec "./get-external-ip.sh" (list "") }}
```

`secrets.yaml`:
```
_sops:
  #...
environment:
  - name: MY_SECRET_VALUE
    value: (encrypted by sops)
```

`helmfile.yaml`:

```
releases:
- name: foo
  values:
  - values.yaml
  secrets:
  - secrets.yaml
```

This doesn't work because `values.yaml` and the decrypted `secrets.yaml` are passed to `helm` to be merged, and helm overrides the array instead of merging or concatenating the arrays.

**Example (works!)**

Instead of `values.yaml` and `secrets.yaml`, you provide a single `secrets.yaml.gotmpl` that is a valid YAML and encrypted by sops:

```
_sops:
  #...
environment:
  -   name: MY_EXTERNAL_IP
      value: |
          {{ exec "./get-external-ip.sh" (list "") }}
  - name: MY_SECRET_VALUE
    value: (encrypted by sops)
```

`helmfile.yaml`:

```
releases:
- name: foo
  secrets:
  - secrets.yaml.gotmpl
```

Helmfile decrypts the gotmpl by handing it over to helm-secrets and then renders the result as a gotmpl file. The end result is that you have a two-element array `environments` that can be just passed to helm.

Resolves #1700

Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
2021-04-06 14:20:42 +09:00
Yujun Zhang a161796dc4
feat: Allow overriding chart via flag (#1751)
Adds `--chart` flag for overriding the selected release's chart ad-hoc-ly like `helmfile --chart $CHART template`.
This is handy when e.g. you want to have an ArgoCD application per each release in your helmfile.yaml, while also providing the ability to customize the release's chart without touching helmfile.yaml.

See https://github.com/roboll/helmfile/issues/1690#issuecomment-812321354 for more context.

Closes #1690
2021-04-06 13:20:41 +09:00
Javier Palacios 261367e7e9
Add `kubectl` hooks for applying file(s) or kustomize (#1736)
This enables you to write a `kubectl-apply` hook more declaratively than writing `command` and `args`:

```
releases:
- name: myapp
  chart: mychart
  hooks:
  - events: ["presync"]
    kubectlApply:
      filename: path/to/manifests
      #kustomize: path/to/kustomize
```
2021-04-06 13:16:35 +09:00
Quan TRAN 5cd0afcfa0
Add documentation about helmfile-fetch and StateValues alias (#1746)
Ref #1743, #1744, #1734
2021-04-01 09:48:58 +09:00
Quan TRAN 1748cbfcea
Add .StateValues as alias of .Values in releaseTemplateDataRelease (#1744)
Ref #1743
2021-04-01 09:47:12 +09:00
Nenad Strainovic 200cae2a68
feat: --show-secrets on diff and apply commands (#1749)
Resolves #1674
2021-04-01 09:41:53 +09:00
astorath b1b7831a90
feat: make --kube-context override helmDefaults (#1673)
This would allow cli flag `--kube-context` to override value in helmDefaults allowing to use different values in local development and CI context.

Co-authored-by: Andrey Tuzhilin <andrey@3adigital.ru>
2021-03-30 16:53:19 +09:00
Quan TRAN 53c6d2f988
Add helmfile-fetch command to downloading and generating charts (#1734) 2021-03-30 16:26:31 +09:00