Commit Graph

119 Commits

Author SHA1 Message Date
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
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
Somtochi Onyekwere acf164c46e Add flag to disable cross namespace references
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-01-29 13:51:06 +01:00
Kingdon Barrett 0498e9e236 Use patch instead of update when adding finalizers
Signed-off-by: Kingdon Barrett <kingdon@weave.works>
2022-01-13 19:39:36 -05:00
Aurel Canciu 2c82071f6c
Update flux pkg components
Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2022-01-07 17:53:07 +01:00
Paulo Gomes 0837f6f34a
Short-circuit event handling
When ExternalEventRecorder is nil, the helm release reference is not used
therefore the function can safely return early.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2021-12-21 14:08:38 +00:00
Paulo Gomes c9b1a4f4f8
Check EventRecorder is not nil
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2021-12-21 14:03:32 +00:00
Stefan Prodan 459984c33d
Verify artifacts integrity
After downloading an artifact, compute its checksum and verify that it matches the original checksum advertised by source-controller.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-12 14:35:42 +02:00
Dylan Arbour 42ec2fb0d1 Nit: update tests to use non-deprecated ValuesFiles
Signed-off-by: Dylan Arbour <arbourd@users.noreply.github.com>
2021-10-14 11:11:14 +02:00
Dylan Arbour b724dcafbb Update the chart if ReconcileStrategy changes
If the ReconcileStrategy is changed (from ChartVersion to Revision for
example), we should update the HelmChart.

Signed-off-by: Dylan Arbour <arbourd@users.noreply.github.com>
2021-10-09 21:50:54 -04:00
Hidde Beydals c079240190 Introduce ReconcileStrategy in HelmChartTemplateSpec
To allow configuring it within the `HelmRelease`.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-08 13:19:55 +02:00
Stefan Prodan e9d31e9f1f
Make the kubeconfig secrets compatible with SOPS
Add `values.yaml` to the supported kubeconfig secret key names in order for SOPS to correctly detect the storage format based on the file extension.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-04 16:22:09 +03: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
Zhongcheng Lao 0ceec2d3fc
Add test case for set with boolean value and set-string behavior
Signed-off-by: Zhongcheng Lao <Zhongcheng.Lao@microsoft.com>
2021-07-23 08:30:47 +08:00
Zhongcheng Lao c0f72e1fc6
Treat quoted values as string when targetPath is set
Signed-off-by: Zhongcheng Lao <Zhongcheng.Lao@microsoft.com>
2021-07-17 16:42:32 +08:00
Dylan Arbour da3186716f Add `ValuesFiles` to HelmChart spec
Signed-off-by: Dylan Arbour <arbourd@users.noreply.github.com>
2021-04-19 10:50:17 -04: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
Somtochi Onyekwere a9e6820999 Record suspension metrics
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-03-17 14:30:09 +01:00
Hidde Beydals 39e6475822 Revert "Record suspend metrics"
https://github.com/fluxcd/helm-controller/pull/234#issuecomment-801000679

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-03-17 13:24:29 +01:00
Somtochi Onyekwere 8b2ba595bf Record suspend metrics
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-03-16 23:45:50 +01:00
Max Jonas Werner 199636f27a
fix: log messages contain '%s'
Before:

{"level":"info","ts":"2021-03-03T12:45:41.305Z","logger":"controller.helmrelease","msg":"could not find optional %s '%s'","reconciler group":"helm.toolkit.fluxcd.io","reconciler kind":"HelmRelease","name":"cert-manager","namespace":"kommander","ConfigMap":{"namespace":"kommander","name":"cert-manager-overrides"}}

After:

{"level":"info","ts":"2021-03-03T13:56:46.365+0100","logger":"controller.helmrelease","msg":"could not find optional ConfigMap 'kommander/cert-manager-overrides'","reconciler group":"helm.toolkit.fluxcd.io","reconciler kind":"HelmRelease","name":"cert-manager","namespace":"kommander"}

Signed-off-by: Max Jonas Werner <mwerner@d2iq.com>
2021-03-03 13:57:51 +01:00
Stefan Prodan a8dcafaf2e
Retry with exponential backoff when fetching artifacts
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-02-26 13:37:45 +02: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
Will Salt 7156abcadf Send specific events for install or upgrade
Signed-off-by: Will Salt <williamejsalt@gmail.com>
2021-02-15 17:20:54 +00:00
Will Salt fcd845c952 add a release deployment event when reconciling a release
Signed-off-by: Will Salt <williamejsalt@gmail.com>
2021-02-15 16:36:19 +00:00
Stefan Prodan 7873fe2022
Add contributing doc
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-02-15 15:18:24 +02:00
Stefan Prodan fc18a045a6
Allow the controller to be run locally
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-02-14 12:10:56 +02: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 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
gtracer a5ab88962a add optional storageNamespace
Signed-off-by: gtracer <ganesha.ashoka@gmail.com>

update comments

Signed-off-by: gtracer <ganesha.ashoka@gmail.com>

make test

Signed-off-by: gtracer <ganesha.ashoka@gmail.com>

revert controller-gen version

Signed-off-by: gtracer <ganesha.ashoka@gmail.com>
2021-01-25 17:09:37 +01:00
Hidde Beydals 32693b8106 Upgrade runtime package to v0.6.2
To include a bug fix to the `ReconcilateAtChangedPredicate`
and renaming to `ReconcileRequestedPredicate`.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-01-14 12:32:34 +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 8f337e743c Ignore missing release on HR delete
This prevents the resource hanging forever if the release does not exist
in the Helm storage because it was either never created, or because it
was already removed by e.g. Kubernetes due to a namespace deletion.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-30 12:04:17 +01:00
Hidde Beydals 19d1316e31 Always remove finalizer on reconcileDelete
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-26 11:09:17 +01:00
Hidde Beydals 5f2f9aaf74 Do not mark suspended resource as not ready
If a resource is marked as suspended we should not perform any
reconciliation action for the resource at all.

This includes updating the status of the resource to a
`Ready==False` state, as this is not an accurate representation of
the resource's state: we have been told to no longer look at it
and with that our last observation freezes in time.

Resource deletions are the sole exception to actions (not) being
performed, as we are duty-bound to remove our finalizer from the
resource to make a deletion succeed.

To make the suspend state still visible to the user, a column has
been added to the Custom Resource Definition which prints the
`.spec.suspend` of every HelmRelease.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-25 19:21:48 +01:00
Hidde Beydals f97352d1f2 Remove code comment
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-25 17:23:36 +01:00
Hidde Beydals ecbdf700f5 Use controller-runtime utils for resource deletion
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-25 17:23:36 +01:00
Hidde Beydals 599f3e814e Use DeletionTimestamp for readiness
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-25 15:33:10 +01:00
Hidde Beydals 03d8bea1da Factor out HelmChart reconciliation bits
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-25 15:14:56 +01:00
Stefan Prodan b59f06e9a7
Implement service account impersonation
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2020-11-24 16:49:13 +02:00
Stefan Prodan b864db2bb8
Requeue after interval on source not found errors
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2020-11-24 13:13:35 +02:00
Hidde Beydals c0156f193c Refactor to adopt k8s standardized Condition type
Changes the condition type to the one introduced in k8s 1.19, including
the newly introduced helpers in place of the old pkg/apis/meta types.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-19 19:00:55 +01:00
Hidde Beydals f18ddbfce8 Detect chart values file divergences
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-18 10:06:45 +01:00
Hidde Beydals b801b23911 Properly detect chart version divergences
This is a regression bug fix due to the introduction of the default
values in the source-controller CRDs.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-18 10:06:40 +01:00
Hidde Beydals bb85850448 Patch status sub-resource
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-17 11:42:42 +01:00
Hidde Beydals 485b6f5fc8 Requeue on chart load and values composition err
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-17 11:38:55 +01:00
Hidde Beydals fa598261e7 Compare artifact <> HelmRelease in enqueuer
The reason for this is the `EnqueueRequestsFromMapFunc` calling the
enqueuer for _both_ the old and the new object, and we only want to act
on the ones that contain a revision different from the one that we have
recorded in the status object of the `HelmRelease`.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-10-28 22:42:29 +01:00
Hidde Beydals a35a8a9707 Do not requeue when chart is not ready
As the watcher should trigger a reconciliation once the artifact
is available.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-10-28 14:26:04 +01:00
Hidde Beydals b3baf39e11 Move dedicated watcher to in-controller watcher
This prevents the resources from getting annotated, and instead uses
the `handler.EnqueueRequestsFromMapFunc` to queue requests based on
changes to the source objects.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-10-28 13:28:11 +01:00