Replies: 5 comments 3 replies
-
I think I understood your issue as, there is a Custom Resource defined, and the Custom Resource Definition needs to be applied to the cluster, but the Custom Resource is invalid before the CRD is deployed, so you can't keep these resources together and apply them at the same time. This is correct, and you're on the right track looking at You can use an additional You need this Kustomization to be applied first, so the second Since this can quickly explode into a large number of reconcilers, many more than you probably want, this usually shakes out a different way for clusters with many CRDs from different sources. The pattern I've heard most commonly: one team (the cluster admin) manages the CRDs in a single Finally another Flux If that sounds too heavyweight for your situation, you can also just make sure "infrastructure" depends on "crds" and pile everything into infrastructure. Usually you want at least three Kustomizations If that also sounds like too much formalism which may be the case depending on your stage of implementation, the quick and dirty way to solve this so it just applies and be eventually consistent without stopping the presses based on the validation failure that you identified, is to set on your Kustomization Be careful when disabling validation though, because Flux's atomicity guarantees are only able to be achieved through this validating before applying. If you have disabled validation and some resources in the repo are invalid, then you will get partial applications and no more atomic apply guarantees. (This is of course why it works.) |
Beta Was this translation helpful? Give feedback.
-
Is there any demo repository solving this problem? |
Beta Was this translation helpful? Give feedback.
-
We are facing an extremely similar issue but it does not get solved even after using dependsOn. We have a crds Kustomization, where we install a helm chart and this helm chart has a crds folder, which contains about 5-6 crds which helm installs into the cluster. This is marked as a success and the tests show that the crds are installed. Another Kustomization applications, which depends on crds is then installed, but still throws up an error which says unable to find Kind of the custom crd we are deploying. I suspect it is because of some time it takes to register the crds with the kube-api or the flux operator is using an older state of the cluster without the new/updated CRD's. The only way I presume this can be solved is using a delay in dependsOn. Can a delay be added in the spec for dependsOn incase we have a large number of crds and the next kustomization has a dependency that all the crds are present on the cluster. |
Beta Was this translation helpful? Give feedback.
-
Try to give a look at https://github.com/spolab/spolab-flux |
Beta Was this translation helpful? Give feedback.
-
This video, while it critiques argocd and provides a solution also applies to fluxcd. Btw, he issue title is worth changing to "Eventual consistency using fluxcd" 😅 . Argo CD Synchronization is BROKEN! It Should Switch to Eventual Consistency! |
Beta Was this translation helpful? Give feedback.
-
We are using the nats-operator in our cluster.
The example specs to set it up are here. We are actually deploying it per namespace, not as a cluster wide operator. Each namespace gets its own operator and cluster.
The nats operator is responsible for creating a CRD that defines the
NatsCluster
resource. The problem I have is that when flux kustomize controller runs, it fails onflux-system False validation failed: error: unable to recognize "1852fed5-e87e-44e6-a432-7608857aa525.yaml": no matches for kind "NatsCluster" in version "nats.io/v1alpha2" False
...because the operator is part of the same
kustomize.yaml
file and hasn't had a chance to spawn and create the CRD yet.The directory structure I have for nats looks like this:
The
bootstrap
folder contains stuff that should not be deployed per namespace as aClusterRole
is not namespaced, so we add a fluxKustomization
to run that only once like so:But the stuff in the
sources/
dir is meant to be overridden per namespace. Thekustomization.yaml
file there looks like this:... and this is pulled in as a base in a namespaced overlay like so:
The problem here is we include the
nats-cluster.yaml
as part of theresources
, but we need to wait for the operator to spin up first to generate that CRD or update it. So, the whole flux kustomization fails. The only way I can get past it now is the hack to comment out thenats-cluster.yaml
-- let the operator come up, then comment it back in.I know the flux Kustomization resource has dependsOn, but this only works for those resource types. This is straight up
kustomize.config.k8s.io/v1beta1
Kustomization
type, and I see no way to provide any kind of alternative dependency or ordering there in the mainKustomize
docs.Is there a way to re-structure this to make it work how I want?
Beta Was this translation helpful? Give feedback.
All reactions