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

replace dynamic client with controller-runtime client #4153

Merged
merged 5 commits into from
Nov 4, 2021

Conversation

skriss
Copy link
Member

@skriss skriss commented Nov 3, 2021

Replaces the dynamic Kubernetes client with
the controller-runtime client, which is easier
to use and can natively perform reads from
the cache.

Closes #3983.

Signed-off-by: Steve Kriss krisss@vmware.com

Replaces the dynamic Kubernetes client with
the controller-runtime client, which is easier
to use and can natively perform reads from
the cache.

Closes projectcontour#3983.

Signed-off-by: Steve Kriss <krisss@vmware.com>
Signed-off-by: Steve Kriss <krisss@vmware.com>
Signed-off-by: Steve Kriss <krisss@vmware.com>
@codecov
Copy link

codecov bot commented Nov 3, 2021

Codecov Report

Merging #4153 (8676e2d) into main (7fa2a53) will increase coverage by 0.61%.
The diff coverage is 25.41%.

❗ Current head 8676e2d differs from pull request most recent head a6aee60. Consider uploading reports for the commit a6aee60 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4153      +/-   ##
==========================================
+ Coverage   72.56%   73.17%   +0.61%     
==========================================
  Files         115      113       -2     
  Lines       10032     9884     -148     
==========================================
- Hits         7280     7233      -47     
+ Misses       2597     2497     -100     
+ Partials      155      154       -1     
Impacted Files Coverage Δ
cmd/contour/certgen.go 26.41% <0.00%> (ø)
cmd/contour/ingressstatus.go 34.37% <ø> (ø)
cmd/contour/leadership.go 0.00% <0.00%> (ø)
cmd/contour/serve.go 12.91% <0.00%> (+0.31%) ⬆️
internal/contour/handler.go 92.00% <ø> (ø)
internal/controller/gateway.go 0.00% <0.00%> (ø)
internal/controller/gatewayclass.go 0.00% <0.00%> (ø)
internal/controller/tcproute.go 0.00% <0.00%> (ø)
internal/controller/udproute.go 0.00% <0.00%> (ø)
internal/k8s/clients.go 0.00% <0.00%> (-20.69%) ⬇️
... and 11 more

Comment on lines +391 to +399
for name, r := range map[string]client.Object{
"httpproxies": &contour_api_v1.HTTPProxy{},
"tlscertificatedelegations": &contour_api_v1.TLSCertificateDelegation{},
"extensionservices": &contour_api_v1alpha1.ExtensionService{},
"contourconfigurations": &contour_api_v1alpha1.ContourConfiguration{},
"services": &corev1.Service{},
"ingresses": &networking_v1.Ingress{},
"ingressclasses": &networking_v1.IngressClass{},
} {
Copy link
Member Author

@skriss skriss Nov 3, 2021

Choose a reason for hiding this comment

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

it seemed easier to just inline these now that they're one-liners each, but if you all prefer this being kept in informers.go / in a DefaultResources() function I can go back to that.

Copy link
Member

Choose a reason for hiding this comment

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

Agree inline is cleaner.

Comment on lines -676 to -677
// Only inform on GatewayAPI if found in the cluster.
if s.clients.ResourcesExist(k8s.GatewayAPIResources()...) {
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 dropped the explicit resources-exist check since it seemed redundant now: startup will fail anyway if you try to enable Gateway API but the resources don't exist. Had the benefit of being able to entirely get rid of the RESTMapper.

@@ -21,29 +21,8 @@ rules:
- ""
resources:
- endpoints
verbs:
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 change was just rearranging things to group them by API group, shouldn't be any actual changes to the rules.

Signed-off-by: Steve Kriss <krisss@vmware.com>
@skriss skriss added the release-note/small A small change that needs one line of explanation in the release notes. label Nov 3, 2021
@skriss skriss marked this pull request as ready for review November 3, 2021 18:34
@skriss skriss requested a review from a team as a code owner November 3, 2021 18:34
@skriss skriss requested review from tsaarni and youngnick and removed request for a team November 3, 2021 18:34
@skriss skriss added the do not merge Don't merge this PR until this label is removed. label Nov 3, 2021
@skriss
Copy link
Member Author

skriss commented Nov 3, 2021

Ready for review but I'd like to do some additional manual testing on this one before merging.

Copy link
Member

@stevesloka stevesloka left a comment

Choose a reason for hiding this comment

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

lgtm pending the smoke tests! There are spots where we could probably just move to controller manager setups to standardize a bit on how we get data, but not for this PR.

Comment on lines +391 to +399
for name, r := range map[string]client.Object{
"httpproxies": &contour_api_v1.HTTPProxy{},
"tlscertificatedelegations": &contour_api_v1.TLSCertificateDelegation{},
"extensionservices": &contour_api_v1alpha1.ExtensionService{},
"contourconfigurations": &contour_api_v1alpha1.ContourConfiguration{},
"services": &corev1.Service{},
"ingresses": &networking_v1.Ingress{},
"ingressclasses": &networking_v1.IngressClass{},
} {
Copy link
Member

Choose a reason for hiding this comment

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

Agree inline is cleaner.

cmd/contour/serve.go Show resolved Hide resolved
@skriss skriss removed the do not merge Don't merge this PR until this label is removed. label Nov 4, 2021
@skriss skriss added this to the 1.20.0 milestone Nov 4, 2021
@skriss
Copy link
Member Author

skriss commented Nov 4, 2021

I deployed it to a cloud cluster, ensured ingress address was updated properly, did some manual smoke-testing and things seemed fine so I think we're good here.

Signed-off-by: Steve Kriss <krisss@vmware.com>
@skriss skriss merged commit cb3ec9a into projectcontour:main Nov 4, 2021
@skriss skriss deleted the rm-dynamic-client branch November 8, 2021 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/small A small change that needs one line of explanation in the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

replace dynamic client with controller-runtime client
3 participants