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

Gateway kuadrant.io/namespace annotation owned by a single controller #520

Merged
merged 3 commits into from
Apr 10, 2024

Conversation

eguzki
Copy link
Contributor

@eguzki eguzki commented Apr 5, 2024

What

The assignment of a gateway to a kuadrant instance is done using the kuadrant.io/namespace annotation. The owner of that annotation was a shared ownership between gateway_kuadrant_controller and kuadrant_controller. This PR moves the full ownership to gateway_kuadrant_controller.

Verification steps

  • Setup the environment:
make local-setup         

Checking the annotations of the istio-ingressgateway gateway

❯ k get gateways istio-ingressgateway -n istio-system -o jsonpath='{.metadata.annotations}' | yq e 'keys' -P

It does not have any kuadrant namespace annotation

- gateway.istio.io/controller-version
- kubectl.kubernetes.io/last-applied-configuration

Request an instance of Kuadrant:

kubectl -n kuadrant-system apply -f - <<EOF
apiVersion: kuadrant.io/v1beta1
kind: Kuadrant
metadata:
  name: kuadrant
spec: {}
EOF

The istio istio-ingressgateway gateway, should be annotated with the kuadrant annotation

❯ k get gateways istio-ingressgateway -n istio-system -o jsonpath='{.metadata.annotations}' | yq e 'keys' -P
- gateway.istio.io/controller-version
- kuadrant.io/namespace
- kubectl.kubernetes.io/last-applied-configuration

Create a new gateway

kubectl -n kuadrant-system apply -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
  name: second
spec:
  gatewayClassName: istio
  listeners:
    - allowedRoutes:
        namespaces:
          from: All
      hostname: '*.example.com'
      name: api
      port: 80
      protocol: HTTP
EOF

Note that the gateway initial spec does not have the kuadrant annotation. The kuadrant controller will add it.

The new gateway second gateway, should be annotated with the kuadrant annotation

❯ k get gateways second -n kuadrant-system -o jsonpath='{.metadata.annotations}' | yq e 'keys' -P
- gateway.istio.io/controller-version
- kuadrant.io/namespace
- kubectl.kubernetes.io/last-applied-configuration

Now, let's delete the kuadrant CR

kubectl delete kuadrant kuadrant -n kuadrant-system 

The istio istio-ingressgateway gateway, must not have the annotation with the kuadrant namespace

❯ k get gateways istio-ingressgateway -n istio-system -o jsonpath='{.metadata.annotations}' | yq e 'keys' -P
- gateway.istio.io/controller-version
- kubectl.kubernetes.io/last-applied-configuration

The new gateway second, must not have the annotation with the kuadrant namespace

❯ k get gateways second -n kuadrant-system -o jsonpath='{.metadata.annotations}' | yq e 'keys' -P
- gateway.istio.io/controller-version
- kubectl.kubernetes.io/last-applied-configuration

@eguzki eguzki force-pushed the gateway-controller-enhancement branch from 5b9fb49 to fdd6072 Compare April 5, 2024 11:29
Copy link

codecov bot commented Apr 5, 2024

Codecov Report

Merging #520 (38d7c8e) into main (ece13e8) will increase coverage by 0.34%.
Report is 25 commits behind head on main.
The diff coverage is 76.27%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #520      +/-   ##
==========================================
+ Coverage   80.20%   80.55%   +0.34%     
==========================================
  Files          64       71       +7     
  Lines        4492     4957     +465     
==========================================
+ Hits         3603     3993     +390     
- Misses        600      648      +48     
- Partials      289      316      +27     
Flag Coverage Δ
integration 71.41% <76.27%> (+0.13%) ⬆️
unit 33.52% <3.38%> (+3.48%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
api/v1beta1 (u) 71.42% <ø> (ø)
api/v1beta2 (u) 88.51% <100.00%> (-2.92%) ⬇️
pkg/common (u) 83.01% <ø> (-5.81%) ⬇️
pkg/istio (u) 75.14% <100.00%> (+1.23%) ⬆️
pkg/log (u) 94.73% <ø> (ø)
pkg/reconcilers (u) ∅ <ø> (∅)
pkg/rlptools (u) 79.77% <ø> (+0.31%) ⬆️
controllers (i) 76.62% <82.66%> (-0.18%) ⬇️
Files Coverage Δ
controllers/kuadrant_controller.go 49.81% <ø> (-3.76%) ⬇️
pkg/library/kuadrant/kuadrant.go 85.29% <66.66%> (-14.71%) ⬇️
controllers/gateway_kuadrant_controller.go 82.85% <84.21%> (+1.72%) ⬆️
pkg/library/mappers/kuadrant_to_gateway.go 60.00% <60.00%> (ø)

... and 12 files with indirect coverage changes

@eguzki eguzki force-pushed the gateway-controller-enhancement branch from 010242a to ad9ef14 Compare April 5, 2024 13:49
@eguzki eguzki marked this pull request as ready for review April 5, 2024 14:05
@eguzki eguzki requested a review from a team as a code owner April 5, 2024 14:05
@eguzki eguzki force-pushed the gateway-controller-enhancement branch from ad9ef14 to f2954a6 Compare April 5, 2024 18:48
Copy link
Member

@didierofrivia didierofrivia left a comment

Choose a reason for hiding this comment

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

Works like a charm! 🍔

@eguzki eguzki force-pushed the gateway-controller-enhancement branch from f2954a6 to 38d7c8e Compare April 10, 2024 13:38
@eguzki eguzki merged commit 76a39f0 into main Apr 10, 2024
20 of 21 checks passed
@eguzki eguzki deleted the gateway-controller-enhancement branch April 10, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants