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

feat: add Gateway API support, instructions on how to integrate with new Istio charms #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ca-scribner
Copy link
Owner

This PR:

  • bumps Knative to 0.15
  • adds a section in README.md describing how you can connect knative to the istio and ingress from istio-k8s and istio-ingress-k8s
  • adds the ingress_class configurations and features needed to use knative with the Gateway API

What doesn't work:

  • any charm release CI (that has been disabled because this fork does not have somewhere to release to)

Todo:

  • refactor the integration tests to use istio-k8s and istio-ingress-k8s (I'm open to doing this here, or as a separate issue)

Testing instructions

There are integration tests here, but they're from the original charm and do not currently use the new istio. For now, manual testing can be done with the instructions in README.md.

This commit adds basic support for Gateway APIs in Knative Serving.  Knative provides a net-gateway-api controller to support the Gateway APIs, but it is not fully supported by Knative's Operator.  This commit thus:

* adds charm config for the `ingress-class`, which can optionally be set to `gateway-api.ingress.networking.knative.dev` to enable the Gateway API mode
* if `ingress-class=gateway-api...`, this commit deploys the net-gateway-api controller and configures it based on charm config

While we deploy and configure net-gateway-api when ingress-class is set to gateway-api, we do not actually remove the net-istio controller from the cluster.  Instead, net-istio is still deployed (but sits idle).  Not sure how to avoid installing it.
@ca-scribner
Copy link
Owner Author

I wasn't sure if I should change the integration tests or not. Right now they use the original istio-pilot/istio-gateway, but I could refactor them to instead use our new istio. I appreciate feedback from reviewers on this. If we want these updates to be pushed back to the kubeflow team's charm, we probably don't want to modify the integration tests anytime soon since they'd be using their own istio.

What we could do is include integration tests for both istio configurations. that way its easy to see which failed, and optionally release anyway (maybe tests with the new istio wouldn't block CI releases?)

@ca-scribner
Copy link
Owner Author

To make this cherry-pickable to the upstream charm, maybe we should pull the CI disabling commit out into a separate PR, that way when things get squashed down those are separate

@IbraAoad
Copy link

I wasn't sure if I should change the integration tests or not. Right now they use the original istio-pilot/istio-gateway, but I could refactor them to instead use our new istio. I appreciate feedback from reviewers on this. If we want these updates to be pushed back to the kubeflow team's charm, we probably don't want to modify the integration tests anytime soon since they'd be using their own istio.

What we could do is include integration tests for both istio configurations. that way its easy to see which failed, and optionally release anyway (maybe tests with the new istio wouldn't block CI releases?)

I've found pytest markers to be very helpful in scenarios like this, we put our itests in a new file and mark them with smth like gateway_tests and in their tox file we do pytest -v -m "not gateway_tests" and maybe introduce a new tox "task?" that only does pytest -v -m "gateway_tests" to run our own tests locally for now until the gateway api becomes the new standard.

README.md Show resolved Hide resolved
--trust \
--config namespace=knative-serving-1 \
--config istio.gateway.namespace=istio-system \
--config domain.name=10.64.140.43.nip.io \ # <-- may be different if you have a different load balancer configuration

Choose a reason for hiding this comment

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

any idea why we need this, shouldn't the gateway name and namespace be enough since it already holds the LB data as it owns it?, what would happen if there's a discrepancy between the domain name used here and the External IP of the loadbalancer owned by the gateway?

Copy link
Owner Author

Choose a reason for hiding this comment

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

This is used to populate the links that knative tells you about. It goes into the config-domain configmap. So if you deploy a knative service called my-knative-thing, you can then do kubectl get route my-knative-thing --output jsonpath="{.status.url}" which would show http://my-knative-thing.my-domain-name.com. the "my-domain-name.com" part comes from this domain.name config. I think this is because we cannot really introspect the hostname based solely on the Gateway due to wildcard hosts

Which makes me wonder if we need to do something similar when using wildcards ourselves. Maybe its just not feasible to introspect those, and instead a human needs to give guidance

README.md Show resolved Hide resolved
protocol: HTTP
hosts:
# wildcard so we can use it for knative, which adds to the front of the domain
- "*.10.64.140.43.nip.io"

Choose a reason for hiding this comment

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

Is the wildcard a prereq here, meaning does the operator by default insert subdomains for workloads it deploys or is it just to add support when needed?, if it's a prereq we will need to do something about the ingress charm to support wildcards as well.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah it is a prereq. All knative urls are my-knative-service.my-domain. So we'll have to support them somehow

# This is analogous to the config-domain configmap
# TODO: defining this gateway config did nothing. Maybe the operator doesn't support it?
{% if ingress_class == 'gateway-api.ingress.networking.knative.dev' %}

Choose a reason for hiding this comment

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

tbh I have no idea what I'm looking at here, what exactly is this API group and what is it used for?

Copy link
Owner Author

@ca-scribner ca-scribner Aug 21, 2024

Choose a reason for hiding this comment

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

😄

this doc might help. the gateway part of this configures the external and internal gateways that knative will use when creating VirtualService or HTTPRoute objects.

by default, knative will use class Istio APIs to create everything. But if we set ingress-class: gateway-api.ingress.networking.knative.dev, that turns on the new gateway APIs. So what the jinja is doing here is:

  • above here, in the if not ingress_class block, that is saying "if we have no ingress_class defined, apply settings for istio-classic"
  • then here, if ingress_class is set to gateway-api, define these gateway settings which are specific to gateway-api
  • a little further down, if ingress_class is set to anything, then add the ingress_class entry in the configmap

Copy link
Owner Author

Choose a reason for hiding this comment

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

its hard to read and I'm happy to edit if you have suggestions. what gave me trouble is that omitting the ingress_class means "use classic istio api", so then there's those odd looking if not ingress_class calls

network:
# Setting this tells net-istio to not reconcile things, I think? If I set this, I don't see any VirtualServices
# created for knative services
ingress-class: gateway-api.ingress.networking.knative.dev

Choose a reason for hiding this comment

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

same as the previous comment, no idea what's this or what it's used for 🥲

Copy link

@IbraAoad IbraAoad left a comment

Choose a reason for hiding this comment

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

This looks good to merge once we create corresponding issues to the things discussed in the review conversations.

@ca-scribner
Copy link
Owner Author

This is functionally complete. Leaving it as a branch for now, but we'll pick it back up again later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants