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: set default router flavor to expressions if KIC >=3.0 and traditional_compatible otherwide #935

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

Conversation

randmonkey
Copy link
Contributor

@randmonkey randmonkey commented Nov 9, 2023

What this PR does / why we need it:

Add kong.router_flavor to set router flavor to:

  • values.env.router_flavor if specified
  • expressions if KIC is enabled and image version >= 3.0.0
  • traditional_compatible otherwise (REVIEW: is it better to leave it empty to let Kong gateway to use the default value)?

Which issue this PR fixes

(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged)

Special notes for your reviewer:

Checklist

[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]

  • PR is based off the current tip of the main branch.
  • Changes are documented under the "Unreleased" header in CHANGELOG.md
  • New or modified sections of values.yaml are documented in the README.md
  • Commits follow the Kong commit message guidelines

@randmonkey randmonkey requested a review from a team as a code owner November 9, 2023 07:48
@randmonkey randmonkey self-assigned this Nov 9, 2023
@randmonkey randmonkey added the enhancement New feature or request label Nov 9, 2023
{{- if (and .Values.ingressController.enabled (semverCompare ">= 3.0.0" (include "kong.effectiveVersion" .Values.ingressController.image))) -}}
expressions
{{- else -}}
traditional_compatible
Copy link
Contributor

Choose a reason for hiding this comment

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

As I understand this also changes the default when KIC is < 3.0.0 from traditional to traditional_compatible, is this intended?

Copy link
Member

Choose a reason for hiding this comment

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

👍 on keeping whatever was the default - traditional for KIC <3.0.

@pmalek
Copy link
Member

pmalek commented Nov 9, 2023

REVIEW: is it better to leave it empty to let Kong gateway to use the default value

On one hand setting this in chart makes this predictable for us. Regardless of Kong Gateway version we use as default, we'll always get the expected behavior. On the other hand though, users might be expecting the Gateway defaults to translate into corresponding chart settings.

We've had a long history of setting the router flavor so I'd say we retain this and keep setting it in the chart. If there'a debate we'd like to have on this I suggest we consider pros and cons of that in a separate issue.

Copy link
Contributor

@czeslavo czeslavo left a comment

Choose a reason for hiding this comment

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

As mentioned on the team sync, we have to keep in mind this won't work as expected with kong/ingress chart. gateway part of the release doesn't know about the controller's ingressController.image. The condition will be executed based on the gateway's ingressController.image (which will be the default from values.yaml - so we accidentally get KIC 3.0 there always if a user for some weird reason didn't change gateway.ingressController.image to something else).

As an example, this change will break Konnect values.yaml where we still want to keep using traditional_compatible router with KIC 2.11/2.12:

controller:
  ingressController:
    image:
      tag: "2.11"
...

gateway:
  image:
    repository: kong/kong-gateway
    tag: "3.4"
...

As this will pick expressions based on the default value of gateway.ingressController.image which is 3.0 now.

EDIT after checking actual results: As in the template there's .Values.ingressController.enabled condition required to set router flavor to expressions, for kong/ingress chart this will always default to traditional_compatible. The problem persists though because the router flavor is not changed based on the KIC version as intended. So, if we set controller.ingressController.image.tag to 3.0 to start using KIC 3.0 in kong/ingress, Gateway's router flavor will still default to traditional_compatible.

I think we have to either:

  • Wait for @rainest's Split the Deployment #923
  • Add some templating to kong/ingress that will somehow override gateway.ingressController.image to what is set in controller.ingressController.image.

@czeslavo
Copy link
Contributor

czeslavo commented Nov 9, 2023

I was trying to come up with some workaround that would make this work with kong/ingress, but I couldn't achieve anything that would satisfy the requirement of helm install kong kong/ingress just setting the expression router based on controller image tag. 😞

I was trying to use .Values.global or templates to override values of the gateway subchart using values of the controller, but that is not possible (there was a proposal in Helm charts repo implementing that, but it was rejected: helm/helm#6876).

The only more-or-less reasonable way I came up with was adding a new variable in kong/kong values (deployment.kong.alignWithControllerVersion) that could allow users to explicitly tell to auto-align gateway's config based on a given controller version. #936 But of course, it has drawbacks, e.g. requires setting an additional value that also should match ingress.ingressController.image.tag to not blow up (that could be validated).

I think I just assured myself that #923 is the only way we can make it work as we expected.

@pmalek
Copy link
Member

pmalek commented Nov 9, 2023

I couldn't find the helm doc page on this but .Subcharts seems to be the thing that we're looking for (at least as a workaround until/if we get to the split Deployment in kong chart).

#937 shows how it could be used to enforce the router flavor in ingress chart using subcharts values.

@czeslavo
Copy link
Contributor

czeslavo commented Nov 9, 2023

I couldn't find the helm doc page on this but .Subcharts seems to be the thing that we're looking for (at least as a workaround until/if we get to the split Deployment in kong chart).

#937 shows how it could be used to enforce the router flavor in ingress chart using subcharts values.

As I understand that would prevent using anything else but expressions with KIC >= 3.0 which might be too rigorous 🤔

Sidenote: If I'm not mistaken, .Subcharts is an equivalent of getting these values from .Values.controller or .Values.gateway.

@pmalek
Copy link
Member

pmalek commented Nov 9, 2023

As I understand that would prevent using anything else but expressions with KIC >= 3.0 which might be too rigorous 🤔

Hmm, yes. We'd like to set this for the user as in perform the defaulting in template code rather than limit the possibilities as #937 is trying to do.

In this case I'm not sure this is possible this way (or at least without massive rewrite of kong chart into something like a gigantic template which would be rendered in ingress using provided subchart values 🤯 )

Sidenote: If I'm not mistaken, .Subcharts is an equivalent of getting these values from .Values.controller or .Values.gateway.

.Subcharts is an object holding fields like .Files, .Values etc.

.Subcharts.controller.Values and .Subcharts.gateway.Values can be used in ingress chart to get values from subcharts.

@czeslavo
Copy link
Contributor

czeslavo commented Nov 9, 2023

@pmalek I came up with another alternative: #939. It sets the router flavor to expressions in kong/ingress and prevents using this kind of flavor with KIC < 3.0. It has a drawback that would make it break when somebody:

  • has kong/ingress release installed with KIC version pinned to one lower than 3.0
  • has router flavor set to expressions already
  • wants to keep using the pinned KIC with the new chart version

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

Successfully merging this pull request may close these issues.

Chart uses the expression router by default
3 participants