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

Add Gateway API and Envoy Gateway install to Calico Enterprise #3638

Merged
merged 42 commits into from
Dec 17, 2024

Conversation

nelljerram
Copy link
Member

Description

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

EnvoyGatewayJobContainerName = "envoy-gateway-certgen"
)

func GatewayAPIResourcesGetter() func() *gatewayAPIResources {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem like something we need to have happen at run time since it will never change but it's redone multiple times when reconciliation happens. This seems to provide an unneeded source of panics that could be caught at build time.

Instead, could we just generate the structures here from the yaml at build time and save them to a file, similar to how we generate the version structures https://github.com/tigera/operator/tree/master/hack/gen-versions using go template?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach of reading from YAML at runtime is one that I've already discussed (and agreed as a reasonable option) during the design phase.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, even if we are going with this approach vs one that generates this at compile time, could this at least be done once at start up stored in some global variable or function?

I don't see why we'd need to run this function more than once when absolutely nothing would change, and we'd avoid missing any issues with CRD generation (since it would fail on startup, which is the next best think to failing at compile time).

This just seems to unnecessarily complicate the runtime render logic for trying to get around transferring CRDs defined in a yaml into go code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's already doing what you think it should do. In other words, it only reads and parses the YAML once. The only reason for the slightly odd (to you) form is to have the resources cache and associated lock internal to the function, instead of being globals that other code might accidentally misuse.

GatewayControllerDeployment *GatewayControllerDeployment `json:"gatewayControllerDeployment,omitempty"`

// Allow optional customization of the gateway certgen job.
GatewayCertgenJob *GatewayCertgenJob `json:"gatewayCertgenJob,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we generally write out api field names. I am assuming Certgen stands for Certificate Generation, meaning it is two words and both words should be capitalized in the field name as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm following the Envoy resources here, which have "certgen" as a single word.

@radTuti radTuti modified the milestones: v1.37.0, v1.38.0 Dec 13, 2024
"github.com/tigera/operator/pkg/render"
)

const ResourceName string = "gatewayapi"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is currently unused.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, removed.

pkg/controller/gatewayapi/gatewayapi_controller.go Outdated Show resolved Hide resolved
pkg/controller/gatewayapi/gatewayapi_controller.go Outdated Show resolved Hide resolved
// the CRDs are left in place even if the GatewayAPI CR is removed again. This is in case
// the customer uses a second (or more) implementation of the Gateway API in addition to the
// one that we are providing here.
crdComponent := render.NewPassthrough(render.GatewayAPICRDs(log)...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some corner cases where this can be problematic, especially since we are using v1alpha CRDs, which are more likely to change:

  • We don't detect if the CRDs are already provided through another mechanism. Potentially, we could get into a fight with another controller or gitops tool that is also reconciling CRDs, in which case we probably don't want to do anything here.
  • If another controller applies CRDs of a different version, we should degrade.
  • Perhaps we can annotate the CRDs we apply, so that we can detect these scenarios?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've invented a concept of a component handler having "create only" operation. PTAL ecb2315

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this going to work when we've updated our CRDs and need to apply the changes?

I think we need to instead know if we're managing the installation or the customer is doing it (as @rene-dekker points allude to).

@rene-dekker, how are we doing this for prometheus and eck? I think prometheus requires a different insallation step, but I can't remember what we do for eck.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this offline and decided to follow up with the right approach for CRDs.

pkg/render/gateway_api.go Show resolved Hide resolved
hack/gen-versions/enterprise.go.tpl Show resolved Hide resolved
pkg/render/gateway_api_resources.yaml Outdated Show resolved Hide resolved
pkg/render/gateway_api.go Outdated Show resolved Hide resolved
pkg/render/gateway_api.go Outdated Show resolved Hide resolved
Ref. tigera#3638 (comment)

The point here is to avoid any possible fighting between our operator and
another component that might also be trying to install CRDs for the Gateway
API, e.g. if a customer is using multiple Gateway API implementations at the
same time.

This change only stops us from fighting.  It's possible to imagine more
sophisticated logic, such as installing _our_ CRDs if they have versions which
are later (or in some way "better") than the existing ones.  But it's not
obvious that that would be what our customers want - e.g. they might _need_ an
older version - and even if it wasn't we could still be fighting with a less
intelligent other component.
1. Follow our standard pattern for namespace creation.

2. Create pull secrets earlier, so as not to glitch the objects that may need them.

3. Fix comment about pull secrets not covering all envoy images; in fact they do!
Plus improve in a few other small ways.
Copy link
Member

@rene-dekker rene-dekker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Otherwise our operator code adds in the default Tigera registry, giving e.g.

    gcr.io/unique-caldron-775/cnx/envoyproxy/envoy:distroless-v1.31.0
@nelljerram nelljerram merged commit a6d7b05 into tigera:master Dec 17, 2024
5 checks passed
@nelljerram nelljerram deleted the gateway-api-cr branch December 17, 2024 12:07
nelljerram added a commit that referenced this pull request Dec 17, 2024
Add Gateway API and Envoy Gateway install to Calico Enterprise

(cherry-pick of #3638 to the branch for v3.21ep1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants