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: allow assigning KongPluginInstallation to GatewayConfiguration and DataPlane #476

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

programmer04
Copy link
Member

@programmer04 programmer04 commented Aug 12, 2024

What this PR does / why we need it:

Kong custom plugin built from Dockerfile

FROM scratch

COPY plugin /

where plugin is a directory that contains handler.lua and schema.lua as described in the official docs.

Image with the aforementioned Kong custom plugin is available publicly under

  • northamerica-northeast1-docker.pkg.dev/k8s-team-playground/plugin-example/myheader -> adds header myheader: roar
  • northamerica-northeast1-docker.pkg.dev/k8s-team-playground/plugin-example/myheader-2 (it's also mirrored in plugin-example-private requires auth) -> adds header newheader: amazing

Those are used in config/samples/gateway-kongplugininstallation-httproute.yaml and submitted as part of this PR and in the integration test.

Functionality is implemented entirely. For each instance of Kong Gateway deployment, a dedicated ConfigMap with a custom plugin is created (based on source ConfigMap made as a result of the successful reconciliation of KongPluginInstallation) and its lifecycle is tied to Kong Gateway. Such an approach although a little bit wasteful, because there are many duplications of ConfigMaps (but it's guaranteed that its size won't exceed 1MiB), greatly simplifies implementation. This is due to the limitation of Kubernetes - it's impossible to mount a ConfigMap from another namespace to a Deployment. Furthermore, it reduces the blast radius of some mistakes, bugs, user actions, etc. to only one Dataplane - each one has its own ConfigMaps and reconciles them on its own.

Which issue this PR fixes

Closes #380

Special notes for your reviewer:

Those "magic" images used in tests and examples will be documented/reworked to make them easy to maintain in the separate issue #465

Maybe more testing would be useful, e.g. with the usage of newly created envtests or more integration ones, I'm open to suggestions that I'm going to address in a separate PR.

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect significant changes

@programmer04 programmer04 added enhancement New feature or request area/feature New feature or request labels Aug 12, 2024
@programmer04 programmer04 added this to the KGO v1.4.x milestone Aug 12, 2024
@programmer04 programmer04 self-assigned this Aug 12, 2024
@programmer04 programmer04 force-pushed the custom-plugin-mount branch 3 times, most recently from 1c8f88f to 6d1469a Compare August 12, 2024 13:48
@programmer04 programmer04 force-pushed the custom-plugin-mount branch 2 times, most recently from f14564b to 61f4b41 Compare August 22, 2024 18:40
@programmer04 programmer04 force-pushed the custom-plugin-mount branch 11 times, most recently from 9e33515 to b0b1da5 Compare September 5, 2024 15:18
@programmer04 programmer04 force-pushed the custom-plugin-mount branch 2 times, most recently from efb4710 to e0b9544 Compare September 8, 2024 17:05
@programmer04 programmer04 force-pushed the custom-plugin-mount branch 7 times, most recently from f6b2a4c to bf5c1da Compare September 11, 2024 07:49
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.

Apart from Patryk's concern about the namespaced Plugin references in the DP CRD, it looks good to me now. 👍

@programmer04 programmer04 force-pushed the custom-plugin-mount branch 2 times, most recently from 9ff849a to 2c374eb Compare September 17, 2024 14:41
@programmer04 programmer04 marked this pull request as draft September 18, 2024 13:51
@programmer04 programmer04 force-pushed the custom-plugin-mount branch 2 times, most recently from a742111 to d96aa1a Compare September 20, 2024 11:10
@programmer04 programmer04 marked this pull request as ready for review September 20, 2024 11:24
@programmer04 programmer04 enabled auto-merge (squash) September 20, 2024 11:25
Copy link
Member

@pmalek pmalek left a comment

Choose a reason for hiding this comment

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

I'm still going through this one but these are the minor nits I found so far.

controller/dataplane/watch.go Show resolved Hide resolved
controller/dataplane/owned_custom_plugins.go Outdated Show resolved Hide resolved
controller/dataplane/controller.go Outdated Show resolved Hide resolved
controller/dataplane/controller.go Outdated Show resolved Hide resolved
controller/dataplane/controller_reconciler_utils.go Outdated Show resolved Hide resolved
controller/dataplane/controller_reconciler_utils.go Outdated Show resolved Hide resolved
controller/dataplane/controller_reconciler_utils.go Outdated Show resolved Hide resolved
programmer04 and others added 2 commits September 24, 2024 11:49
…and DataPlane

Co-authored-by: Patryk Małek <patryk.malek@konghq.com>
Co-authored-by: Grzegorz Burzyński <czeslavo@gmail.com>
@programmer04 programmer04 enabled auto-merge (squash) September 24, 2024 09:52
@programmer04 programmer04 merged commit d99325c into main Sep 24, 2024
21 checks passed
@programmer04 programmer04 deleted the custom-plugin-mount branch September 24, 2024 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/feature New feature or request enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow configuring additional plugins for Dataplane - Kong Gateway
3 participants