Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

WIP: Migrate to kubebuilder 3 #21

Merged
merged 24 commits into from
Aug 21, 2022
Merged

Conversation

laurentgrangeau
Copy link
Contributor

This PR try to fix #20 and support Kubernetes 1.22 and above

Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
Signed-off-by: Laurent Grangeau <laurent.grangeau@gmail.com>
@MrTrustor
Copy link
Member

I added a commit to this PR that fixes the 2 tests that didn't pass. They were caused by the fact that we used r.Update(...) instead of r.Status().Update(...) to update the status of the custom resource (and the status wasn't updated). I vaguely remember having issues with this when I first wrote this and having to not follow the documentation. I think they fixed that in kubebuilder since then, hence why it was broken now.

I also updated the version of kubebuilder in the cloudbuild files, as this was necessary. It broke them, but since you reworked the Makefile extensively, I'm going to let you fix those :)

@laurentgrangeau
Copy link
Contributor Author

Thanks @MrTrustor for fixing the remaining tests. I fixed the Google Cloud Build build and it's now working.
Due to huge changes from Kubebuilder 2 to Kubebuilder 3, and breaking apis changes in Kubernetes, I think this release need testing.
If everything is OK, I will release a v0.3 that should work with Kubernetes 1.20.
Please let me know if everything is right.

@MrTrustor
Copy link
Member

I'm hitting an error when trying the config/samples/networking_v1alpha3_fqdnnetworkpolicy_valid_noport.yaml file. You don't seem to have modified this part of the code, so I'm not sure if it's actually you who introduced this error.

Appart from that, everything seems to be working as expected.

kubectl apply -f networking_v1alpha3_fqdnnetworkpolicy_valid_noport.yaml
Error from server (InternalError): error when creating "networking_v1alpha3_fqdnnetworkpolicy_valid_noport.yaml": Internal error occurred: failed calling webhook "vfqdnnetworkpolicy.kb.io": failed to call webhook: Post "https://fqdnnetworkpolicies-webhook-service.fqdnnetworkpolicies-system.svc:443/validate-networking-gke-io-v1alpha3-fqdnnetworkpolicy?timeout=10s": EOF

In the controller logs:

1.6599998096066353e+09	INFO	fqdnnetworkpolicy-resource	validate create	{"name": "fqdnnetworkpolicy-valid-noport"}
2022/08/08 23:03:29 http: panic serving 10.244.0.1:56389: runtime error: invalid memory address or nil pointer dereference
goroutine 155 [running]:
net/http.(*conn).serve.func1()
	/usr/local/go/src/net/http/server.go:1825 +0xbf
panic({0x153c5e0, 0x24120d0})
	/usr/local/go/src/runtime/panic.go:844 +0x258
github.com/GoogleCloudPlatform/gke-fqdnnetworkpolicies-golang/api/v1alpha3.(*FQDNNetworkPolicy).ValidatePorts(0xc000953180)
	/workspace/api/v1alpha3/fqdnnetworkpolicy_webhook.go:135 +0xf09
github.com/GoogleCloudPlatform/gke-fqdnnetworkpolicies-golang/api/v1alpha3.(*FQDNNetworkPolicy).ValidateCreate(0xc000953180)
	/workspace/api/v1alpha3/fqdnnetworkpolicy_webhook.go:92 +0xd9
sigs.k8s.io/controller-runtime/pkg/webhook/admission.(*validatingHandler).Handle(_, {_, _}, {{{0xc000a81da0, 0x24}, {{0xc00062d488, 0x11}, {0xc00070f0c8, 0x8}, {0xc00062d4a0, ...}}, ...}})
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.1/pkg/webhook/admission/validator.go:71 +0x239
sigs.k8s.io/controller-runtime/pkg/webhook/admission.(*Webhook).Handle(_, {_, _}, {{{0xc000a81da0, 0x24}, {{0xc00062d488, 0x11}, {0xc00070f0c8, 0x8}, {0xc00062d4a0, ...}}, ...}})
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.1/pkg/webhook/admission/webhook.go:146 +0xa2
sigs.k8s.io/controller-runtime/pkg/webhook/admission.(*Webhook).ServeHTTP(0xc000265fc0, {0x7fcaa09be278?, 0xc0007de9b0}, 0xc000541300)
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.12.1/pkg/webhook/admission/http.go:98 +0xe90
github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerInFlight.func1({0x7fcaa09be278, 0xc0007de9b0}, 0x194c700?)
	/go/pkg/mod/github.com/prometheus/client_golang@v1.12.1/prometheus/promhttp/instrument_server.go:40 +0xd4
net/http.HandlerFunc.ServeHTTP(0x194c720?, {0x7fcaa09be278?, 0xc0007de9b0?}, 0xc000703a38?)
	/usr/local/go/src/net/http/server.go:2084 +0x2f
github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerCounter.func1({0x194c720?, 0xc00082a0e0?}, 0xc000541300)
	/go/pkg/mod/github.com/prometheus/client_golang@v1.12.1/prometheus/promhttp/instrument_server.go:117 +0xaa
net/http.HandlerFunc.ServeHTTP(0x2434460?, {0x194c720?, 0xc00082a0e0?}, 0xc0007039c0?)
	/usr/local/go/src/net/http/server.go:2084 +0x2f
github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerDuration.func2({0x194c720, 0xc00082a0e0}, 0xc000541300)
	/go/pkg/mod/github.com/prometheus/client_golang@v1.12.1/prometheus/promhttp/instrument_server.go:84 +0xbf
net/http.HandlerFunc.ServeHTTP(0x2d3428db90?, {0x194c720?, 0xc00082a0e0?}, 0xc0005daf50?)
	/usr/local/go/src/net/http/server.go:2084 +0x2f
net/http.(*ServeMux).ServeHTTP(0xc00038894c?, {0x194c720, 0xc00082a0e0}, 0xc000541300)
	/usr/local/go/src/net/http/server.go:2462 +0x149
net/http.serverHandler.ServeHTTP({0x19401f8?}, {0x194c720, 0xc00082a0e0}, 0xc000541300)
	/usr/local/go/src/net/http/server.go:2916 +0x43b
net/http.(*conn).serve(0xc000616140, {0x194d2e0, 0xc00063c3c0})
	/usr/local/go/src/net/http/server.go:1966 +0x5d7
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:3071 +0x4db

@Cessaa
Copy link

Cessaa commented Aug 9, 2022

Hello,

Thank you for the work you have done. I tried too. I think I've succeeded in installing.
But after writing the rule it says it cannot be updated.

Capture

The rule I entered is as follows

https://github.com/GoogleCloudPlatform/gke-fqdnnetworkpolicies-golang/blob/wip-migrate-to-kubebuilder-3/config/samples/networking_v1alpha3_fqdnnetworkpolicy_valid.yaml

Can you also post v0.3? Maybe I made a mistake while editing yamls

@Cessaa
Copy link

Cessaa commented Aug 17, 2022

Hello,

Is there any process?

@laurentgrangeau
Copy link
Contributor Author

HI,
I'm going to merge this pull request into the main branch and create a 0.3 release to test.
Can you please create these 2 issues in GitHub so that we can track and fix them ?

@laurentgrangeau laurentgrangeau merged commit 62f85f2 into main Aug 21, 2022
@laurentgrangeau laurentgrangeau deleted the wip-migrate-to-kubebuilder-3 branch August 21, 2022 15:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kubernetes version 1.22 and above does not support "networking.gke.io/v1alpha2"
3 participants