voyagermesh / voyager

🚀 Secure L7/L4 (HAProxy) Ingress Controller for Kubernetes
https://voyagermesh.com
Apache License 2.0
1.35k stars 134 forks source link

When using Voyager as a dependency subchart, Helm will complain about non-existent `voyager.appscode.com/v1beta1` #1415

Open alexkreidler opened 5 years ago

alexkreidler commented 5 years ago

I am using Voyager as a dependency subchart of a larger project. This means that Helm will

  1. Put voyager in the same release as the larger project
  2. Put the voyager operator and other resources in the release namespace

I am happy with this setup. However, when I do a fresh helm install I get:

Error: unable to recognize "": no matches for kind "Ingress" in version "voyager.appscode.com/v1beta1"

I think this is because Helm is trying to create my Ingress resource before it has actually created Voyager's apiregistration.k8s.io/v1beta1 APIService which actually defines voyager.appscode.com/v1beta1, so at the time of creation, no such api extension actually exists.

The simplest solution to this issue would to use Helm hooks (e.g. "helm.sh/hook": "pre-install") to make sure that Voyager's APIService is created before any other resources in the same release. The pre-install hook will have no impact on regular Voyager installations.

I will open a PR and link to it here. Hopefully this is a quick fix that will help everyone who wants to follow this pattern with Voyager.

Thanks for a great project!

alexkreidler commented 5 years ago

After trying to use the pre-install hook I've realized that Kubernetes needs to actually provision the APIService and then finally the voyager-operator pod for the Ingress CRD to be created here:

https://github.com/appscode/voyager/blob/39cac5f3d26832fe3599c0a98b7dc9c4348f68b0/pkg/operator/operator.go#L106-L114

This means that even if Helm waits for the APIService to be created, the pod will still be spinning up and the CRDs will not exist yet at the time of validation.

A solution to this problem which would allow for the workflow of using Voyager as a dependency would be to keep the CRD resources statically in the Helm chart for Voyager and create them at Helm install-time.

This would allow us to use the crd-install Helm hook to be able to create an Ingress in the parent app while using the CRD from the voyager subchart. The history of the CRD issue and the crd-hook solution is described here

This is more work than simply adding a pre-install hook, but also seems to me to make more sense, however I haven't looked in detail at Voyager's architecture so I don't know if there's a specific reason not to do this.

However, it would be great to support the workflow of using Voyager as a subchart in a large Helm app.

mikeurbach commented 4 years ago

Are there any updates or recommendations for this issue? Using the 12.0.0 version of this chart, I still run into this situation.

I would definitely like to support the ease of using Voyager as a subchart if I can help contribute.