Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for CRDs existence at runtime #52

Closed
nlewo opened this issue Nov 18, 2019 · 7 comments
Closed

Wait for CRDs existence at runtime #52

nlewo opened this issue Nov 18, 2019 · 7 comments
Labels
carvel triage This issue has not yet been reviewed for validity discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution

Comments

@nlewo
Copy link

nlewo commented Nov 18, 2019

kapp cannot deploy Gatekeeper with a Gatekeeper configuration because the configuration uses a CRD created by the Gatekeeper controller itself.

For instance, in https://github.com/open-policy-agent/gatekeeper#constraint-templates, a template is created. This template is used by the Gatekeeper controller to create the CRD K8sRequiredLabels. This kind can be used by the user to create constraints such as https://github.com/open-policy-agent/gatekeeper#constraints.

So, currently, we first need to deploy the Gatekeeper controller, and then add the configuration custom resource in the app. Otherwise, kapp refuses to deploy the app because the CRD K8sRequiredLabels is missing.

In this kind of scenario, I think kapp should be able to wait for CRDs at runtime. This could be specified as a annotation in the custom resource metadata.

WDYT?

@cppforlife
Copy link
Contributor

cppforlife commented Nov 18, 2019

hmm, i dont think ive seen a project that dynamically creates crd (for a good reason).

2 reasons currently kapp cares about crds:
a. should it insert namespace into CR (depending on if CRD is namespaced)
b. determine when it should create/delete CR (delete is an interesting case as well)

given kapp's separation of diff stage from apply, it's challenging to deal with point (a), given that info isnt available in the diffing stage, unless we ask users to specify an annotation that lets us know if it's namespaced or not (though this becomes duplicate data).

regarding point (b), creation could be dealt with as you've described (may be with addition of timeout). deletion is a bit harded since we dont know when CRD is deleted, so kapp cant help you to make sure CRs are deleted before CRD (may be k8s have some internal logic to deal with that gracefully).

i think your suggestion of adding annotations is definitely one way. another alternative that might be interesting is adding a "cluster-fulfilled" resource (in this example for a CRD). by having a dedicated resource we could plug it into order hierarchy (https://github.com/k14s/kapp/blob/develop/docs/apply-ordering.md). ill think more about this while i'm attending kubecon.

@cppforlife cppforlife added the discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution label Nov 18, 2019
@cppforlife cppforlife added the in progress Work has begun by a community member or a maintainer; this issue may be included in a future release label Dec 5, 2019
@cppforlife cppforlife removed the in progress Work has begun by a community member or a maintainer; this issue may be included in a future release label Mar 23, 2020
@voor
Copy link

voor commented May 3, 2020

Dex dynamically creates its CRDs as well.

@kferrone
Copy link

In my case the CRDs are created by FluxCDs Helm Operator. A ton of Helm charts will bundle their CRDs and therefore the CRDs are dynamically created when I use the HelmRelease kind from FluxCD. So kapp can't really see what is included in a HelmRelease and I can't tell a custom resource to simply wait for the operator from the helmRelease to complete because the CRDs are not in the cluster yet.

@pivotaljohn
Copy link
Contributor

The Carvel team is taking a serious swing at addressing this need generically (i.e. as a first-class feature of the order hierarchy): #194

@pivotaljohn pivotaljohn changed the title Wait for CRDs existance at runtime Wait for CRDs existence at runtime Feb 22, 2021
@praveenrewar
Copy link
Member

praveenrewar commented Dec 6, 2021

We have added support of kapp.k14s.io/exists annotation (available in v0.43.0) which can be used to wait for resources that are not owned by kapp.
For the above mentioned example of gatekeeper, we might wanna add a few change-groups and change-rules as well (to deploy the Constraint Templates after the pods go into the ready state). Please refer to this gist for reference.

@renuy
Copy link
Contributor

renuy commented Dec 9, 2021

@nlewo, Do try this out, and let us know how it goes.
Thanks

@github-actions github-actions bot added the carvel triage This issue has not yet been reviewed for validity label Dec 9, 2021
@nlewo
Copy link
Author

nlewo commented Dec 9, 2021

@renuy I'm sorry, i moved to some other stuffs and no longer use kapp (not because i find something better, just because i no longer have the need).

btw, thx for the ping ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
carvel triage This issue has not yet been reviewed for validity discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution
Projects
None yet
Development

No branches or pull requests

7 participants