Hi,
Not sure if the sample controller qualifies as "dev", sorry if this is
the wrong list.
I have been learning Kubernetes. To make sure I understood how it works,
I have re-implemented the sample controller. The code, if anyone is
interested, is at
https://github.com/espindola/sample-controller-from-scratch
Some of the differences are expected from being implemented today: It
uses the v1 API instead of v1beta and therefore has the schema that v1
requires.
It also includes a fix for
https://github.com/kubernetes/sample-controller/issues/75 (assuming that
it is actually an issue).
Other differences are a personal preference. As a user I am not very
found of large yaml files and as a developer I try to avoid auto
generated code. The sample controller then registers its own CRD and
uses reflection to handle the various types it watches instead of auto
generating code for that.
The tests are also completely local by mocking the http transport. That
is no replacement for integration testing, but I think provide a really
good first line of defense while development and are much faster than a
integration tests could ever be:
$ go test -count=100 ./pkg/controller
ok
github.com/espindola/sample-controller/pkg/controller 0.245s
And still have very good coverage:
$ go test ./pkg/controller -coverprofile cover.out -coverpkg ./pkg/controller,./pkg/kubeapi
ok
github.com/espindola/sample-controller/pkg/controller 0.012s
coverage: 97.3% of statements in ./pkg/controller, ./pkg/kubeapi
And a shameless plug:
I have used wireshark to help me understand the protocol. That is only
possible if the tls keys are saved somewhere. I wrote
https://github.com/kubernetes/kubernetes/pull/95414
In order to do it. Do I have to do something else on that pull request?
I am honestly lost on the process.
Cheers,
Rafael