Open danehans opened 4 years ago
@jpeach @stevesloka thoughts on how to manage the CRDs? Since the CRDs are quite large and relatively constant, should we consider something like go-bindata or go-yaml to marshal the CRD yamls into Go structs?
What CRDs are you referring to @danehans? What do you need to manage? Sorry not following the issue described here.
I assume we're talking about exactly the set of CRDs that are defined in https://github.com/projectcontour/contour/blob/master/examples/contour/01-crds.yaml, right?
I don't think the operator necessarily needs to manage the CRDs itself; rather, the CRDs can be packaged with the operator. In the case of OLM, the CRDs would be in the operator's CSV metadata, if I understand correctly.
I don't think the operator necessarily needs to manage the CRDs itself; rather, the CRDs can be packaged with the operator.
If the operator upgrades contour controller versions, then I think that it ought to upgrade the CRD, since the versions are often locked or interdependent.
I assume we're talking about exactly the set of CRDs that are defined in https://github.com/projectcontour/contour/blob/master/examples/contour/01-crds.yaml, right?
@Miciah that is correct.
If the operator upgrades contour controller versions, then I think that it ought to upgrade the CRD, since the versions are often locked or interdependent.
@jpeach do you have any recommendations for managing the CRD's? Are either of the approach I suggest above viable?
If the operator upgrades contour controller versions, then I think that it ought to upgrade the CRD, since the versions are often locked or interdependent.
@jpeach do you have any recommendations for managing the CRD's?
The best that I can come up with for now is for the operator to bundle the CRDs with go-bindata. At build time, you could pull the versioned YAML from https://projectcontour.io/quickstart/vxxx/contour.yaml
(we could add a mapping for just the CRD) and package them. New Contour releases would need new operator releases.
Longer term, maybe shipping some sort of OCI Artifact, or a CRD-only helm chart would let the operator automatically pull CRDs at the right version.
However, as Contour deployments evolve, maybe the operator will need to release at the same cadence to track those changes.
On the other hand, installing the operator requires installing it's own CRD. Maybe the operator install process would also install the Contour API CRDs?
Here's an interesting article about go-bindata and related projects; the article raises concerns around the project status of https://github.com/jteeuwen/go-bindata and compares some alternatives: https://tech.townsourced.com/post/embedding-static-files-in-go/
go-bindata is now at https://github.com/go-bindata/go-bindata
How are these as short-term and long-term goals?
Short-term, we should add an API that controls which CRDs the operator instantiates (HTTPProxy CRD, Service APIs CRDs).
Long-term, the same API should additionally control which resources Contour responds to (Ingress, HTTPProxy, Service APIs, and any future additions).
We'd like to get the short-term goal for v1alpha1, but failing that, the operator needs to at least create the 3 CRDs in https://github.com/projectcontour/contour/blob/main/examples/contour/01-crds.yaml.
Looks like https://github.com/go-bindata/go-bindata is not actively maintained, and there is discussion of changing to https://github.com/kevinburke/go-bindata in Kubernetes: https://github.com/kubernetes/kubernetes/issues/96169
Looks like https://github.com/go-bindata/go-bindata is not actively maintained, and there is discussion of changing to https://github.com/kevinburke/go-bindata in Kubernetes: kubernetes/kubernetes#96169
Apparently embed is coming to Go 1.16.
xref: https://github.com/projectcontour/contour-operator/pull/120 that manages CRDs through a make workflow. This should suffice for v1alpha1. Additional Contour CRD management can be addressed post v1alpha1.
You should be able to create the CRD right from the apis
package that is exposed from Contour today, no need to parse into yaml and back out.
So I poked around with this a bit. It's been a while since I last did this (https://github.com/upmc-enterprises/elasticsearch-operator/blob/master/pkg/k8sutil/k8sutil.go#L174-L187) and things have changed a bit. =)
I made this repo to play with and works, however, the code gen stuff is a problem unless we can find a way to generate the specs in go and not yaml: https://github.com/stevesloka/createcrd/blob/main/main.go
Please describe the problem you have Add support for managing Contour CRDs (i.e. HTTPProxy) through a
CustomResourceDefinition
resource./cc @jpeach @Miciah