Commit Graph

45 Commits

Author SHA1 Message Date
Nic Cope defa322852 Remove reconcilers and utilities pertaining to workloads
https://github.com/crossplane/crossplane/issues/1755

This removes support for the secret propagation and target controllers that each
Kubernetes Cluster managed resource implemented before workloads were deprecated.
See the above issue for context.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-10-16 19:54:18 -07:00
hasheddan a23862526f
Assert to resource.Object once in APIUpdatingApplicator
This eliminates an extraneous assertion to metav1.Object in the Apply
method of the APIUpdatingApplicator by asserting to resource.Object at
the beginning of the function.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-09-04 09:33:44 -05:00
hasheddan 2274effb45
Update with desired object in APIUpdatingApplicator
This modifies the behavior of the APIUpdatingApplicator to update with
the desired object by setting its resource version to that of the
current. This ensures that a successful update will result in the object
being modified to match the desired by default. Consumers of this
Applicator no longer are required to pass in an UpdateFn to avoid no-op
updates.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-09-03 22:37:14 -05:00
hasheddan 3420b651d6
Update with object that is gotten in APIUpdatingApplicator
This changes APIUpdatingApplicator to make its Update call
with the object it gets rather than the one passed so that
the default behavior is a no-op rather than a guaranteed
error on mismatched resource versions.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-05-12 15:15:27 -05:00
Nic Cope 70b21471b6 Add a generic ConnectionPropagator
This is effectively identical to the existing ManagedConnectionPropagator, but
propagates from any ConnectionSecretOwner, rather than requiring the much larger
and more specific Managed interface. This allows this propagator to be used to
propagate from managed resources to claims and also from composite resources to
requirements.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-23 13:04:38 -07:00
Nic Cope 55a4bb6323
Merge pull request #149 from muvaf/applyfix
apply should work for objects with only generateName
2020-04-15 22:01:04 -07:00
Muvaffak Onus 3301bfef95
apply should work for objects with only generateName
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-04-14 20:35:44 +03:00
Muvaffak Onus fbeeb71921
Make APIFinalizer interface compatible with all Kubernetes resources
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2020-04-13 17:02:04 +03:00
Nic Cope cf8d3a6a26 Make connection secret propagation UID-agnostic
This allows propagation to function even when the propagating and/or propagated
secrets have been deleted and recreated, and thus allocated new UIDs.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-05 15:16:25 -07:00
Nic Cope b8b606426d Introduce an updating Applicator
This is roughly the same functionality as controllerutil.CreateOrUpdate, albeit
a little simpler. This variant is useful to us because it satisfies our
Applicator interface.

The key difference between the patching and updating applicators is that the
patching applicator will leave any existing, unset fields untouched (to the
extent that a JSON merge patch allows), while the updating applicator will
always update any existing object to exactly match the desired object.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-02 14:28:38 -07:00
Nic Cope ee9b68e00c Introduce a distinct secret type for connection secrets
This allows resource claims and managed resources to adopt existing orphaned
connection secrets without needing to be concerned with the fact that they
might be adopting an existing secret that is unrelated to Crossplane.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-02 14:28:38 -07:00
Nic Cope 51d293df2f Don't require callers to pass a client.Client to Applicator implementations
The Apply method of the resource.Applicator interface took a client.Client
largely because it was extracted from the pre-existing resource.Apply function
to allow pluggable Apply implementations. Now that we have types that satisfy
resource.Applicator it makes more sense for those types to include a client,
rather than being passed one for every Apply call.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-04-01 18:23:17 -07:00
hasheddan 16aa98bd07 Update go mod and refs with crossplane org name
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-02-18 18:17:32 -06:00
Nic Cope 034c58db2c Break reconcilers out into distinct packages
I'm hoping this will help us pass in loggers and eventers using variadic options
without awkward names like WithClaimBindingReconcilerLogger. This is a huge diff
but there's no functional changes - only moving things around and renaming them.

I was hoping we'd be able to do with without a breaking API change by using type
aliases, but doing so would create cyclic imports, because the new reconciler
packages depend on the resource package, which is where we'd need to create the
type alias to the reconciler packages.

I've broken up api.go (which contained most of the 'Kubernetes API' - i.e.
default - implementations of most of the pluggable interfaces used by our
reconcilers) into several files. My heuristic here was:

* If the implementation is used by a single reconciler, put it in that
  reconciler's package.
* If the implementation is used by more than one reconciler, put it in the
  resource package.

Signed-off-by: Nic Cope <negz@rk0n.org>
2020-01-14 19:52:53 -08:00
Daniel Mangum 5ece4af54b Implement Target interface and reconciler (#103)
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-01-14 12:36:41 -08:00
Daniel Mangum d5c9dedd2a secret reconciler: allow for propagation to multiple secrets (#92)
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2020-01-06 16:51:27 -05:00
Nic Cope ca4b6b46c9 Mirror PersistentVolume ReclaimPolicy semantics
This commit changes the meaning of the resource claim resource policy to match
https://kubernetes.io/docs/concepts/storage/persistent-volumes/#reclaiming as
closely as possible, minus the deprecated 'Recycle' policy. Previously the
reclaim policy dictated only what happened to the external resource when its
managed resource was deleted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-11-19 14:43:25 -08:00
Nic Cope 8fc49848d6 Set binding phase after update when unbinding
Previously we set the binding phase to unbound, then called Update(), which
reset the binding status to the API server value before we called
Status().Update() to persist it.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-11-02 02:16:32 -07:00
Nic Cope a3a5f918ac Add managed resource finalizer immediately before creating
This commit moves where we set the finalizer for managed resources to right
before creating them, not at the beginning of the reconcile. This means we'll be
less likely to encounter issues where we can't delete a managed resource because
we could never create it in the first place, but we added a finalizer.

* By the time we get here we know our Observe call worked. If (for example) our
  cloud provider credentials were completely wrong, we'd never proceed far
  enough to add the finalizer.
* If Observe works but Create fails (for example because we had RO cloud
  provider credentials) we would already have added the finalizer, but...
* When the managed resource was deleted we'd be able to Observe that the
  external resource does not exist (because we were never able to Create it) and
  thus would not call Delete on the external resource and go straight to
  unpublishing credentials and removing the finalizer.

This commit also renames and refactors a bunch of our interfaces to use less
obtuse names. Previously sometimes a "finalize" method unbound a managed
resource, while at other times it removed the finalizer. Similarly, finalizers
were added in "initialize". We now have a 'Binder' interface with bind and
unbind methods, and two 'Finalizer' interfaces (one for Claim, and one for
Managed) that add and remove finalizers, as you would expect.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-11-01 15:48:09 -07:00
Nic Cope 4fbddd0d00 Clean up managed resource reconciler tests
No functional updates to the code here, just tidying up the tests a bit to
ensure they all mock out their various moving parts via options.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-31 12:35:28 -07:00
Nic Cope 551efff860 Add tests for external name annotation back-propagation
Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-24 21:07:40 -07:00
Nic Cope 799c22bda6 Set managed resource claim ref at binding time
We already set this reference at dynamic provisioning time, but we need it set
for (bound) statically provisioned managed resources too, so we set it
(potentially again) at binding time.

We must still set the reference at dynamic provisioning time in order to ensure
reconciles are queued for dynamically provisioned managed resources when they
become available.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-24 21:07:40 -07:00
Nic Cope a2e24876e0 Use custom types for secret references
This allows us to require that name (and namespace where appropriate) are set at
the CRD level. In the case of cluster scoped resources that reference secrets
this is less surprising than defaulting to the `default` namespace when the
namespace is omitted.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-22 17:13:21 -07:00
Nic Cope 9f5188e0cb Assume resources, classes, and providers are cluster scoped
Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-22 17:13:21 -07:00
Nic Cope a310ee6a4a Remove support for portable resource classes
This commit renames "non portable resource class" back to "resource class", and
requires that resource claims reference a (non portable) resource class in any
namespace.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-22 17:12:36 -07:00
muvaffak onus d72012f1c2 Use managed resource name as external name (#45)
* - Introduces Initializer hook to managed reconciler.
- ManagedNameAsExternalName is introduced and used
  by default by all managed reconcilers.

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>

* GetExternalName and SetExternalName functions are implemented

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>

* - Unit tests for ManagedNameAsExternalName struct
- Move ExternalNameAnnotationKey into meta package.

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>

* Remove Establisher mechanism and port existing
establisher to Initializer.

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>

* Fix claim's external name annotation propagation to
the managed resource.

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-10-15 10:23:05 -07:00
Nic Cope 15eb580eec
Merge pull request #42 from negz/spreadingsecrets
Constantly propagate connection secrets
2019-10-09 14:09:27 -07:00
Muvaffak Onus 41dbfa349a Use new naming scheme for managed resources.
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
2019-10-09 21:49:54 +03:00
Nic Cope 894481e637 Propagate connection secrets
This commit allows constant propagation of connection secrets from managed
resources to their bound resource claims. It does this by updating the existing
APIManagedConnectionPropagator to add 'propagation annotations', which can be
used by a new 'secret propagating reconciler' to watch both secrets for constant
propagation. The predicates and enqueue handler required to implement this are
included.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-10-08 00:25:11 -07:00
Nic Cope 5230aa5383
Merge pull request #13 from hasheddan/portable-class
Implement portable classes
2019-09-11 21:29:03 -07:00
hasheddan 06cc35d1e3 class to nonportable class
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2019-09-11 22:59:59 -05:00
hasheddan 161ab47fb3 portable and nonportable
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2019-09-11 16:23:44 -05:00
hasheddan 5f7248620b remove CreateOrUpdate in favor of controller-runtime
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2019-09-11 09:11:55 -05:00
Nic Cope 06b6b7dd87 Make writeConnectionSecretToRef optional
https://github.com/crossplaneio/crossplane/issues/719

The resource claim reconciler (and API definitions) consider
writeConnectionSecretToRef to be optional, but the managed resource reconciler
fails if it is not specified. This change aligns the codebase on the reference
being optional. Managed resources that do not specify a secret reference will
provision successfully without publishing their connection details to a secret.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-08-27 19:55:29 -07:00
hasheddan 7d786e2dff runtime migration: strip apis and update dependencies
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2019-08-20 09:27:20 -05:00
hasheddan a72525edae kubebuilderv2: update core packages and tooling
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Co-authored-by: Muvaffak Onus <onus.muvaffak@gmail.com>
Co-authored-by: Jared Watts <jbw976@gmail.com>
Co-authored-by: hasheddan <georgedanielmangum@gmail.com>
2019-08-13 17:39:59 -05:00
hasheddan 9c60da21bc strongly typed phase one: implement default class reconciler for strongly typed resource classes
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Co-authored-by: Nic Cope <negz@rk0n.org>
2019-08-02 09:59:19 -05:00
Nic Cope 1a3451d074 Merge pull request #603 from muvaf/comment-impl
Implement Generic Managed Reconciler
2019-07-31 00:12:26 -07:00
Nic Cope 0681f18c20 Fix typo in license headers
This looks suspiciously like a find and replace bug.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-07-30 21:07:12 -07:00
Nic Cope 91598b2e3f Add a shared managed resource reconciler
This reconciler can be used to reconcile any resource that satisfies the Managed
interface.

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-07-23 12:37:19 -07:00
hasheddan d787a8c9cf header typos: correct author spelling
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2019-07-17 19:20:04 -05:00
Nic Cope b3da55f2be Update all copyrights to 2019
This commit was generated via s/Copyright 2018/Copyright 2019/g

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-07-10 20:16:40 -07:00
Nic Cope fcb9e3663a Create managed resources in their resource class's namespace
https://github.com/crossplaneio/crossplane/issues/92

This returns to our historical behaviour of creating managed resources in the
namespace of thier resource class, not that of their resource claim. I believe
this pattern to be flawed, but mostly changed it in order to leverage owner
references (which cannot cross namespaces) in order to allow a claim to watch
the resources it controls.

Instead we maintain the historical behaviour for the time being, using a custom
event handler to enqueue requests for a resource's claim (reference).

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-06-27 00:20:40 -07:00
Nic Cope 6e3d341349 Follow API conventions for object reference fields
I had previously attempted to standardise on fooReference for an ObjectReference
to a Foo, because we had a mix of fooRef and fooReference. Turns out the API
conventions document has a position on this and says we should use fooRef. I've
kept the actual Go fields named 'FooReference' for readability, but renamed the
struct tags to 'fooRef'. I've also renamed 'writeConnectionSecretTo' to
'writeConnectionSecretToRef' since it is also a reference.

https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#object-references

Signed-off-by: Nic Cope <negz@rk0n.org>
2019-06-26 11:40:11 -07:00
Nic Cope 68a7580935 Add new resource claim reconciler.
Signed-off-by: Nic Cope <negz@rk0n.org>
2019-06-24 23:47:11 -07:00