Commit Graph

264 Commits

Author SHA1 Message Date
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
Soule BA c579e71430
add native support for sops decryption/encryption with Vault
If implemented, the kustomize controller will be able to retrieve a
secret containing a VAULT TOKEN and use it to decrypt the sops encrypted
master key. It will then use it to decrypt the data key and finally use the data
key to decrypt the final data.

Signed-off-by: Soule BA <bah.soule@gmail.com>
2022-01-19 21:59:10 +01:00
Paulo Gomes 50c043eb4f
Refactor fuzzing
Structure the fuzz implementation to be closer to what go native will support.
Add Makefile target to enable smoketesting fuzzers.
Add smoketest as CI workflow.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-01-14 15:38:24 +00: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
Stefan Prodan 02c6708362
Update fluxcd/pkg/ssa to exclude the status field from apply
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-13 18:50:56 +02: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
Somtochi Onyekwere f6403df16f Add test for varsub in secret
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-11-25 12:34:20 +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 c610944139
SOPS: Fix dotenv decryption error reporting
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-19 11:10:10 +03:00
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 f133d2cb5f
Fix HPA v2beta1 validation
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-12 11:50:11 +03: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 b837b8f629
Fix flapping kstatus test due to rate limits
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-07 17:52:55 +03:00
Stefan Prodan ad2fe66dbf
Merge pull request #441 from darkowlzz/use-testenv
Replace envtest with testenv
2021-10-07 14:06:34 +03:00
Sunny dd3935ce8e Replace envtest with testenv
testenv now supports provisioning users. Replace envtest with testenv.

Also, reorder the cleanup to stop the test environment before stopping
the file server to avoid anything in the cluster trying to connect to
the file server after it's stopped.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-07 16:21:22 +05:30
Stefan Prodan dba56a569e
Add example for `.spec.wait` usage
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-07 11:37:39 +03:00
Sunny b7abdf2b84 envtest: Add cancellable context to stop controllers
In suite test, the context created by SetupSignalHandler() watches for
shutdown signal to cancel the context. This makes it possible to stop
the controllers by sending a kill signal that cancels the context.

This change allows controller context cancellation by creating another
context from SetupSignalHandler() context with a CancelFunc that's
called at the end of the test, instead of sending a kill signal.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-06 19:15:47 +05:30
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
Stefan Prodan 9c8f284b7f
Add `spec.wait` usage to the API docs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-09-30 18:35:40 +03:00
Stefan Prodan 468f00e416
Implement health checking for all resources
- Add `.spec.wait` optional boolean field to API
- Wait for all applied resources to become ready when `.spec.wait` is set to `true`

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-09-30 18:35:39 +03:00
Stefan Prodan 8baead9b2e
Add e2e test for CRDs+CRs reconciliation using cert-manager
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-09-30 18:35:39 +03:00
Stefan Prodan 97bbc59eb6
Skip finalizer pruning when impersonation fails
When impersonation fails, emit an event with the stale objects and continue with the finalization as this is not a retryable error.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-09-30 18:35:39 +03:00
Stefan Prodan 69069c3ab3
Refactor reconciliation into actions
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-09-30 18:35:39 +03:00
Stefan Prodan b33e3b3449
Update the status when health checking starts
Set the healthiness status to progressing and specify the health check timeout in the condition message.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-09-30 18:35:39 +03:00
Stefan Prodan 1e01d800c5
Implement reconciliation using server-side apply
Reconciler behaviour:
- Creates an inventory of objects to be applied (persisted in-cluster under `.status.inventory`).
- Applies first custom resource definitions (CRDs) and namespaces, waits for them to register and only then applies the custom resources.
- Validates all resources with server-side dry-run apply (namespaced objects must contain `metadata.namespace`, defaulting to the `default` namespace is no longer supported).
- Reconciles only the resources that drifted.
- Prunes the objects that were previously applied but are missing from the current inventory.
- Emits events for only the resources that where created, configured or deleted.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-09-30 18:34:40 +03:00
Max Jonas Werner 435815c2a5
fix: don't skip all errors when recording health check status
fixes #432

Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-09-30 15:31:02 +02:00
Stefan Prodan 14329c6fa0
Refactor tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-09-10 16:51:22 +03:00
Michal Schott 72bc54477a
Filter dryrun errors for senstive data.
Signed-off-by: Michal Schott <michal.schott@onegini.com>
2021-09-08 16:32:18 +02:00
Michal Schott cb93667050
Redact secret data.
Signed-off-by: Michal Schott <michal.schott@onegini.com>
2021-09-03 21:52:22 +02:00
Stefan Prodan 16c451ba40
Add GC owner reference tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-19 17:15:04 +03:00