Commit Graph

48 Commits

Author SHA1 Message Date
Hidde Beydals f24cf9dc83
helm: enable DNS with AllowDNSLookups feature gate
This allows install and upgrade actions to use DNS lookups while
rendering Helm templates after it got disabled in Helm due to possible
security risks.

It is enabled (globally) on the controller by configuring
`--feature-gates=AllowDNSLookups=true`.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-03-01 13:55:13 +01:00
Hidde Beydals 38ea587370
Change to `helm.toolkit.fluxcd.io/driftDetection`
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-03-01 13:04:13 +01:00
Hidde Beydals 8389593288
diff: prettify premature diff log
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-03-01 10:27:46 +01:00
Hidde Beydals 9153649f23
diff: add premature diff debug log
As there are currently no other utilities to properly see what change
the controller detected, this allows people to have an insight into
the observed changes by configuring the controller with
`--log-level=debug`.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-03-01 10:25:07 +01:00
Hidde Beydals c93e5e1908
diff: additional test cases
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-03-01 09:36:43 +01:00
Hidde Beydals b7d8244496
diff: allow exclusion of specific objects
This allows a specific object from a release manifest to be excluded
from drift detection by labeling or annotating it with:
`helm.toolkit.fluxcd.io/diff: disabled`.

Using a Kustomize post renderer definition in a HelmRelease, this can
be used to ignore any object from an arbitrary chart.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-03-01 09:36:43 +01:00
Hidde Beydals 1240f20183
Enable experimental drift detection
This enables experimental drift detection of cluster state compared to
the current manifest data from the Helm storage's manifest blob.

Drift detection works based on the already proven approach of the
kustomize-controller's SSA package, and utilizes the managed field
configured by the controller since `v0.12.2`.

This feature is planned to go out of experimental once the further
controller rewrite has been finished, and the state of the Helm storage
itself is more fault tolerant.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-03-01 09:36:43 +01:00
Hidde Beydals 8a9ba1c12c
helm: propagate context to install and upgrade
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-02-27 10:32:44 +01:00
Hidde Beydals 362a27173e Patch CRDs with origin labels
This allows the applied CRDs to be traced using the same labels as
currently applied to resources using a Kustomize post-render.

Kustomize is not used here as the apply logic for CRDs is different
from the approach used during releasing, where we inject the labels
in such a way that they are written back to the Helm storage in the
rendered manifest. This to match Helm's logic from which our present
code is already derived (buth with support for policies).

This also moves the full responsibility of dealing with the install
of CRDs to ourselves, as we no longer fall back to Helm's logic when
`Create` is configured as a policy during a Helm install. As this
would not allow us to add the labels.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2023-01-31 15:09:21 +00:00
stoetti 5ea57b72ee assign the value of 'DisableOpenApiValidation' from the HelmRelease-resource to the helm-command 2022-12-20 14:22:27 +00:00
Mac Chaffee 9bcf125e2c
Disable caching of secrets and configmaps by default.
You can re-enabled caching of secrets by starting the
controller with the argument '--feature-gates=CacheSecretsAndConfigMaps=true'

Signed-off-by: Mac Chaffee <machaffe@renci.org>
2022-12-19 09:53:01 -05:00
Hidde Beydals d19b470412 kube: configure proper account impersonation NS
Fixing a regression introduced in #480 which would always pick the
namespace of the release. In addition, historically seen the
configuration of the impersonation username while making use of a
KubeConfig has never worked correctly, this has been adressed as well.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-06-07 12:52:36 +02:00
Hidde Beydals 1bed542fe4 internal/kube: get REST config from runtime
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-12 12:55:36 +02:00
Hidde Beydals 5784f0644a kube: explicitly set ConfigFlags.CacheDir to nil
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-12 12:18:41 +02:00
Hidde Beydals 4371610e4b Cherry-pick kube changes from dev
This is a partial cherry-pick of commit ae4f499e87, including
changes around `kube`. This to include some of the changes around the
construction of the ConfigFlags RESTClientGetter, as an attempt to
solve token refresh issues.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-12 12:18:41 +02:00
Paulo Gomes 6f4ca28c9a
Add flags to control kubeconfig support
Two new flags were added to allow users to enable the
use of user.Exec and InsecureTLS in the kubeconfigs
provided remote apply reconciliations.

Breaking change: both functionalities are no longer
enabled by default.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-03-31 14:51:38 +01:00
Tomek Rękawek 5b1b1ce642 Support targeted Patches in the PostRenderer specification.
Signed-off-by: Tomek Rękawek <rekawek@adobe.com>
2022-03-11 14:34:28 +01:00
Stefan Prodan 1410615554
Set QPS and Burst when impersonating service account
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-02-21 14:25:27 +02:00
Samuel Torres 7d6c0f7c47 Add disableWait property on Helm uninstall
This commit changes the default behavior of the Helm uninstall action
to wait for all resources to be deleted, and introduces a
`.spec.uninstall.disableWait` flag to disable this behavior.

Signed-off-by: Samuel Torres <samuelpirestorres@gmail.com>
2022-02-16 12:09:29 +01:00
Stefan Prodan 0173eaa0df
Allow setting a default service account for impersonation
Introduce the flag `--default-service-account` for allowing cluster admins to enforce impersonation for resources reconciliation.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-31 12:09:39 +02:00
Aurel Canciu 2c82071f6c
Update flux pkg components
Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2022-01-07 17:53:07 +01:00
Sunny 91eb550b19
Remove old util ObjectKey
Replace old utility function ObjectKey with controller-runtime's
client.ObjectKeyFromObject.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-08-01 03:40:10 +05:30
Hidde Beydals 5f3d3ec3c3 Enquote annotations in expected test result
Enquoting int variables as annotations is beter, and the result of an
upstream patch.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-09 13:30:47 +02:00
Hidde Beydals 44ea1d90ce Update dependencies
Controller-runtime has been updated to `v0.9.0`, K8s dependencies to
`v0.21.1`, and all `fluxcd/pkg` and other dependencies to the versions
that have matching dependencies and/or build constraints.

This includes an update of Helm to `v3.6.0`, and an update of the
Kustomize API to match `v4.1.x`.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-09 13:30:47 +02:00
Santosh Kewat f48b8ab953 Added support for helm waitForJobs
Signed-off-by: Santosh Kewat <santoshkewat.bitmesra@gmail.com>

Added support for helm waitForJobs

Signed-off-by: Santosh Kewat <santoshkewat.bitmesra@gmail.com>

Minor fixes

Signed-off-by: Santosh Kewat <santoshkewat.bitmesra@gmail.com>

Changed WaitForJobs to DisableWaitForJobs

Signed-off-by: Santosh Kewat <santoshkewat.bitmesra@gmail.com>

Minor fixes

Signed-off-by: Santosh Kewat <santoshkewat.bitmesra@gmail.com>

Changed WaitForJobs to DisableWaitForJobs

Signed-off-by: Santosh Kewat <santoshkewat.bitmesra@gmail.com>

Removed unnecessary update to v2alpha1

Signed-off-by: Santosh Kewat <santoshkewat.bitmesra@gmail.com>
2021-06-01 18:47:54 +05:30
Hidde Beydals d832b350dd Give CRD policy precedence over skipCRDs field
This gives the in the previous MINOR release introduced CRD policy
precedence, avoiding `skipCRDs is set to false and crds is set to
Skip` errors when the `skipCRDs` field is omitted.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-05-10 14:01:46 +02:00
Hidde Beydals 2de60467bb Restore log buffer size to 5
Changed in a6cc150aa6 without a clear
reason, may be restored in the future but this depends on
a6cc150aa6 (r617706942)

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-04-21 18:44:03 +02:00
Alexander Berger 4b6085518a Fix typos
Signed-off-by: Alexander Berger <alex-berger@gmx.ch>
2021-04-20 14:21:36 +02:00
Alexander Berger defee3d26a Integrate feedback from hiddeco
Signed-off-by: Alexander Berger <alex-berger@gmx.ch>
2021-04-20 14:21:36 +02:00
Alexander Berger a6cc150aa6 Initial support for HelmRelease for upgrading CRDs
Signed-off-by: Alexander Berger <alex-berger@gmx.ch>
2021-04-20 14:21:36 +02:00
Hidde Beydals 314472efb7 Capture (debug) logs from Helm actions
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-03-25 16:08:52 +01:00
Hidde Beydals b2385cb634 Enable devel flag for install and upgrade actions
This provides richer debugging information for wait timeouts, e.g.

```
wait.go:225: [debug] Service does not have load balancer ingress IP
address: deis/deis-builder
wait.go:225: [debug] Service does not have load balancer ingress IP
address: deis/deis-builder
```

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-03-25 16:08:52 +01:00
Hidde Beydals 879cf5b46d Label release resources with HelmRelease origin
This commit adds a new post renderer that labels all resources with
`helm.toolkit.fluxcd.io/name` and `helm.toolkit.fluxcd.io/namespace`
so their source of origin can be traced back by e.g. the Flux UI.

The post renderer makes use of the Kustomize API without running
a full Kustomize build, by making directly use of the builtin
`LabelTransformerPlugin` on a `ResMap` that has been constructed
from the bytes of the `bytes.Buffer` given by Helm.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-03-18 21:32:18 +01:00
Dylan Arbour 368ca98306 Update pkg/runtime to v0.8.2
pkg/runtime v0.8.2 introduces runtime/transform which includes
`MergeMaps`:
https://github.com/fluxcd/pkg/pull/85

Signed-off-by: Dylan Arbour <arbourd@users.noreply.github.com>
2021-02-15 18:10:19 -05:00
Hidde Beydals dcf0d93e84 Add tests for Kustomize post renderer
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-02-04 09:34:56 +01:00
Hidde Beydals c8c8246342 Optimize Kustomize post renderer
* Use constants for APIVersion and Kind in Kustomization config
* Remove redundant JSON marshal of strategic merge patches
* Factor out Kustomization build wrapper and add notes about settings

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-02-03 23:12:18 +01:00
Hidde Beydals 622a87a663 Depend on the Kustomize API from `fluxcd/pkg`
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-02-03 20:02:19 +01:00
Alexander Berger 7db84ac307 Add support for Kustomize based PostRenderer as built-in post renderer.
Signed-off-by: Alexander Berger <alex-berger@gmx.ch>
2021-02-03 15:29:51 +01:00
Hidde Beydals e511cb8af4 Upgrade controller-runtime to v0.7.0
This commit upgrades the `controller-runtime` dependency to `v0.7.0`,
including all changes required to make all wiring work again.

- Upgrade `runtime` to v0.6.0 to include `controller-runtime` changes.
- Loggers have been removed from the reconcilers and are now retrieved
  from the `context.Context` passed to the `Reconcile` method and
  downwards functions.
- Logger configuration flags are now bound to the flag set using
  `BindFlags` from `runtime/logger`, ensuring the same contract across
  GitOps Toolkit controllers, and the `--log-json` flag has been
  deprecated in favour of the `--log-encoding=json` default.
- The `ChangePredicate` from `runtime` has changed to a
  `ReconcilateAtChangedPredicate`, and is now chained with the
  `GenerationChangedPredicate` from `controller-runtime` using
  `predicate.Or`.
- Signatures that made use of `runtime.Object` have changed to
  `client.Object`, removing the requirement to e.g. call
  `runtime.Object#Object`.
- The `leader-election-role` was changed, as leader election now works
  via the `coordination/v1` API.

Other notable changes:

- `util.ObjectKey` was added to easily construct a `client.ObjectKey` /
  `types.NamespacedName` from a `metav1.Object`.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-01-11 17:41:49 +01:00
Hidde Beydals 5e4bd8fe80 Support Helm's NS creation for TargetNamespace
This adds support for creating the target release namespace if it is not
present which can be be useful in certain scenarios.

Note that when the release is uninstalled, the namespace is not removed
and remains on the cluster, and managing your namespace _outside_ of
the HelmRelease is advised.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-27 17:54:19 +01:00
Hidde Beydals 7ac2a41e1a Change copyright to Flux authors
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-10-27 17:55:18 +01:00
Hidde Beydals 15914beca1 Support cross-cluster Helm releases
This is an initial implementation for cross-cluster Helm release
support that relies on a KubeConfig secret, and a reference to it in
the HelmRelease resource.

If set, all actions taken by the Helm runner are executed using the
KubeConfig from the secret. The Helm storage is stored on the remote
cluster in a namespace that equals to the namespace of the HelmRelease
in the managing cluster, the release itself is made in either this
namespace, or the configured TargetNamespace. In any case, both are
expected to exist and/or created beforehand.

Other references to Kubernetes resources in the HelmRelease, like
ValuesReference resources, are expected to exist on the managing
cluster.
2020-10-20 21:30:56 +02:00
Hidde Beydals 899e8bedc7 Configure release namespace in runner constructor 2020-10-02 19:05:45 +02:00
Hidde Beydals accd4762fe Promote API to v2beta1 2020-09-30 19:37:23 +02:00
Hidde Beydals 68a8f62a41 Use `ObserveLastRelease` in garbage collector
Which uses `Last()` instead of `Deployed()` to ensure we garbage
collect Helm releases with statuses other than `deployed`,
e.g. `failed`.
2020-09-25 16:18:15 +02:00
Hidde Beydals 4a9a04aa4f Factor out and restructure various elements
* Move `ReleaseRevision` function to util
* Rename `release` method to `reconileRelease` to match
  `reconcileChart`
* Refactor chart artifact download to make use of a temporary file,
  which is removed as soon as the tarbal has been loaded into memory
2020-09-25 16:03:44 +02:00
Hidde Beydals 7cf267c15c Factor out util functions 2020-09-25 15:40:45 +02:00
Hidde Beydals c526837d76 Factor out Helm actions into runner package 2020-09-25 15:40:41 +02:00