Commit Graph

202 Commits

Author SHA1 Message Date
Stefan Prodan 3090eff734
Refactor: Acquire artifacts with `fluxcd/pkg/http/fetch`
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-10 15:30:58 +03:00
Stefan Prodan 06e91e047b
Refactor: Use impersonation from `fluxcd/pkg/runtime/client`
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-07 17:36:41 +03:00
Stefan Prodan 731188e45b
Refactor: Extract generator to internal package
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-07 12:49:36 +03:00
Stefan Prodan 06ce60f7bf
Refactor: Extract decrytor to internal package
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-06 19:45:12 +03:00
Max Jonas Werner c3c4cc13ac
support alternative kustomization file names
`KustomizeGenerator.WriteFile` now detects alternative kustomization
file names such as `kustomization.yml` and `Kustomization`.

closes #737

Signed-off-by: Max Jonas Werner <max@e13.dev>
2022-10-04 15:34:00 +02:00
Stefan Prodan 65a58330fc
Fix health checking for global objects
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-09-14 12:32:49 +03:00
Stefan Prodan 928f22df5c
Reconcile Kubernetes class type objects in a dedicated stage
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-09-02 11:31:54 +03:00
Santosh Kaluskar e486234e4c Enable RecoverPanic option on reconciler
Signed-off-by: Santosh Kaluskar <dtshbl@gmail.com>
2022-08-13 21:05:10 +05:30
Stefan Prodan a7d790f1b2
Add support for OCIRepository sources
- allow `OCIRepository` to be specified in `sourceRef.kind`
- react to `OCIRepository` artifacts events
- add end-to-end test for OCI repositories

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-08 18:26:03 +03:00
Stefan Prodan cfd5200fbb
Retry downloading the artifact on not found errors
- Extract the artifact operations such as download, verify, untar into a dedicated struct
- Introduce a dedicated type for artifact not found errors
- On artifact not found errors, log the error, update the ready status message and requeue the object
- Retry the artifact download at the interval set with `--requeue-dependency` (defaults to 30s)

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-01 13:55:47 +03:00
Somtochi Onyekwere 13044520c1 Pass polling options to impersonation client
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-06-28 15:28:56 +01:00
Stefan Prodan cafbe253a1
Disallow remote bases usage in Kustomize overlays
Add an optional flag for disabling remote bases. While the `--no-remote-bases` is set to `false` by default, Flux users are encouraged to enable it on production system for security and performance reasons. Using Kustomize remote bases means that kustomize-controller must clone the remote repositories on every reconciliation instead of using the source-controller artifacts cache. Allowing remote bases on multi-tenant clusters, means platform admins have no control over which repositories make up the desired state.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-04-27 14:54:43 +03:00
Hidde Beydals cda51febc7
Merge pull request #631 from cwyl02/ychen/exp-backoff-retry 2022-04-22 09:45:45 +02:00
Sanskar Jaiswal d499ed8063 Ensure generated temp dir is absolute on all OSes
Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
2022-04-22 09:01:46 +02:00
York Chen 827f814f2f
feat: flags to configure exponential backoff retry
Signed-off-by: York Chen <ychen@d2iq.com>
2022-04-21 10:09:39 -04:00
Hidde Beydals 880587f20d generator: ensure remote build dirs can be reached
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-20 17:12:33 +02:00
Hidde Beydals f4528fb25d controllers: use own Kustomize FS implementation
For details, see: https://github.com/fluxcd/pkg/pull/262

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-15 15:48:23 +02:00
Hidde Beydals 105ebd9f47 controllers: improve decryptor and add tests
- Refactored recursion while iterating over Kustomization files.
  References of files that have been visited are cached, and not
  visited again. In addition, symlinks are confirmed to not traverse
  outside the working directory.
- Optimized various bits around (un)marshalling (encrypted) data, and
  YAML -> JSON -> YAML roundtrips are prevented where not required.
- Added support for decrypting INI Kustomize EnvSource references using
  the dedicated SOPS store for the format.
- Introduced support for decrypting Kustomize FileSources:
  https://pkg.go.dev/sigs.k8s.io/kustomize@v1.0.2/pkg/types#DataSources

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-14 09:17:43 +02:00
Paulo Gomes d29032e914
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-04-01 10:13:55 +01:00
Hidde Beydals db5777f06c Ensure annotations are prefixed with Group FQDN
This to facilitate improvements on the notification-controller side,
where annotations prefixed with the FQDN of the Group of the Involved
Object will be transformed into "fields".

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-23 22:30:31 +01:00
Hidde Beydals 855d57c491 Use new standardized meta and runtime pkgs
This includes an update of the source-controller to v0.22.0, to pull in
the v1beta2 API which makes use of the same packages.

Co-authored-by: Sunny <darkowlzz@protonmail.com>
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-18 12:04:39 +01:00
Stefan Prodan d56695a93b
Allow shared ownership of in-cluster objects applied with kubectl
Introduce an annotation that configures kustomize-controller to co-manage objects applied with kubectl.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-03-04 12:37:30 +02:00
harshi1122 f123852771 'Done'
Signed-off-by: harshi1122 <harshitha1155@gmail.com>
2022-02-18 14:55:40 +05:30
Stefan Prodan 65aaa1d69a
Ensure object are finalized under impersonation
If the service account used for impersonation has been deleted, skip pruning, log the error and continue with finalization to allow tenants removals from clusters.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-31 13:20:12 +02:00
Stefan Prodan f353ba44a7
Introduce a dedicated manager for status updates to avoid conflicts
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-31 11:29:54 +02:00
Stefan Prodan 38541078fa
Revoke kubectl managed fields ownership
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-31 11:25:11 +02:00
Stefan Prodan 4d7cba91b0
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-27 18:25:02 +02:00
Stefan Prodan 518c8a021b
Allow disabling cross-namespace references
Introduce the flag `--no-cross-namespace-refs` (defaults to false) for allowing cluster admins to disable cross-namespace references to sources.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-26 22:50:10 +02:00
Stefan Prodan 4ee01a2db0
Fix preflight validation
Validate that the resources built with kustomize conform to the Kubernetes API conventions before passing them to the server-side apply engine.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-21 13:05:40 +02:00
Stefan Prodan b18584a652
Merge pull request #535 from kingdonb/patch-finalizers
Use patch instead of update when adding finalizers
2022-01-14 08:24:26 +02:00
Kingdon Barrett 441b48aeef Use patch instead of update when adding finalizers
Signed-off-by: Kingdon Barrett <kingdon@weave.works>
2022-01-13 19:44:10 -05:00
Florian Fl Bauer 8435a5ba41 If applied, this commit will solve race condition when using two Kustomizations with the same SourceRef
Signed-off-by: Florian Fl Bauer <florian.fl.bauer@deutschebahn.com>
2022-01-07 14:17:40 +01:00
Stefan Prodan 00257e0cc9
Merge pull request #478 from fluxcd/go-v1.17
Update Go to v1.17 and controller-runtime to v0.11
2022-01-05 18:08:38 +02:00
Paulo Gomes facda8b422
Check EventRecorder is not nil
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2021-12-21 21:10:43 +00:00
Aurel Canciu ec9fdb1550
Update flux pkg components
Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2021-12-20 14:50:41 +01:00
Stefan Prodan 1badc828b4
Replace deprecated dependencies
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-23 14:21:21 +02:00
Stefan Prodan bedb53e0fa
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:03:58 +02:00
Stefan Prodan 0ce7c1267e
Allow disabling the reconciliation of in-cluster resources
Introduce `kustomize.toolkit.fluxcd.io/reconcile` annotation. When set to `disabled`, the controller will no longer apply changes from source, nor it will prune the annotated resource.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-09 10:50:52 +02:00
Stefan Prodan 4958b9c8ce
Warn when secrets are not decrypted before apply
If decryption is not enabled, SOPS encrypted secrets will fail to apply with a validation error that doesn't give any hints. It's better to exit early and throw an error that tells users to enable decryption.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-08 15:58:27 +02:00
Stefan Prodan f2715a74c8
Set delete propagation policy to background
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-08 15:02:12 +02:00
Rishabh Bohra b8cebd3838
chore: remove deprecated io/ioutil
Signed-off-by: Rishabh Bohra <rishabhbohra01@gmail.com>
2021-10-29 20:28:25 +05:30
Stefan Prodan 7a26305dc8
Fix cluster scope detection of applied objects
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-19 09:34:18 +03:00
Somtochi Onyekwere 84a88d5878 Decrypt dotenv files
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-17 15:27:04 +01:00
Stefan Prodan a292f28699
Fix drift detection in Secrets and ConfigMaps
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-11 16:26:01 +03:00
Stefan Prodan 7282308883
Fix SSA upstream bugs for Kubernetes < 1.22
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-10 15:28:12 +03:00
Stefan Prodan cd5b6930b3
Fix inventory panic for v1beta1 objects
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-08 17:48:05 +03:00
Stefan Prodan 652da7f1e4
Guard against waiting deadlock
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-08 10:04:23 +03:00
Stefan Prodan 6346591f02
Use ssa package from fluxcd/pkg
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-01 10:21:15 +03:00
Stefan Prodan d0222867e6
Skip pruning for objects with a different owner
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-09-30 18:35:40 +03:00
Stefan Prodan 64084ea03b
Add test for reconciling an empty source
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-09-30 18:35:40 +03:00