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(kuma-dp): rework on the virtual probes to support probing tcp and grpc ports #10624

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

jijiechen
Copy link
Member

Checklist prior to review

Implements this MADR: gRPC and TCP probes

  • Link to relevant issue as well as docs and UI issues
  • This will not break child repos: it doesn't hardcode values (.e.g "kumahq" as a image registry) and it will work on Windows, system specific functions like syscall.Mkfifo have equivalent implementation on the other OS --
  • Tests (Unit test, E2E tests, manual test on universal and k8s)
    • tested with unit and manual tests
    • Don't forget ci/ labels to run additional/fewer tests
  • Do you need to update UPGRADE.md? --
    • No, it's compatible
  • Does it need to be backported according to the backporting policy? (this GH action will add "backport" label based on these file globs, if you want to prevent it from adding the "backport" label use no-backport-autolabel label)
    • No

Changelog: Supported TCP and gRPC probes for data planes running on Kubernetes

@jijiechen jijiechen added the ci/run-full-matrix PR: Runs all possible e2e test combination (expensive use carefully) label Jun 25, 2024
@jijiechen jijiechen requested a review from a team as a code owner June 25, 2024 03:19
@jijiechen jijiechen requested review from bartsmykla and lukidzi and removed request for a team June 25, 2024 03:19
@@ -310,33 +310,5 @@ message Dataplane {
// defined at a Mesh level.
MetricsBackend metrics = 2;

message Probes {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we can remove it like this. What about universal?

Copy link
Member Author

@jijiechen jijiechen Jun 25, 2024

Choose a reason for hiding this comment

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

Checked the code, this field only serves Kubernetes scenarios. For universal, there is another field called serviceProbe. Docs at here

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure that's not going to be fine from a backward compat pov

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @lahabana I don't quite understand why removing this field will break backward compatibility?
Without this field, we can still parse the existing dataplane objects stored in the DB when people upgrade their versions. So I think this is not a break change.

Copy link
Contributor

Choose a reason for hiding this comment

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

There're might be users who rely on this functionality on Universal. Backward compatibility means not only being able to parse the format, but also preserve the functionality. Usually we mark the field as deprecated and remove it after the 2 minor releases

Copy link
Member Author

@jijiechen jijiechen Jul 22, 2024

Choose a reason for hiding this comment

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

Thanks for the explanation of the "Backward compatibility", I agree with your view of "not only being able to parse the format, but also preserve the functionality". I meant that you guys may be confused this field with the other one serviceProbe which serves Universal scenarios. The field "probes" here was only serving Kubernetes scenarios. @lobkovilya

@jijiechen
Copy link
Member Author

Hi reviewers, sorry that this is a large PR. To help you review the code easily, let me explain what are included in this PR.
This PR basicly refactors the existing HTTP-only "virtual probes" and implements the new model of "virtual probe" that support all three kinds of pod probes: TCP, gRPC and HTTP.

Here are the break down tasks:

  1. introduce a new component into kuma-dp to start the virtual probe server, it's an HTTP server. This is placed at directory app/kuma-dp/pkg/dataplane/probes
  2. configure kuma-dp from the injector.go to run the virtual probe server according to user's auto-injector configuration
  3. in the function of OverridePodProbes that is called by injector.go, change the existing virtual probe overriding to support all the three kinds of probes
  4. exclude the virtual probe server port on the ways of settings of transparent proxy:
    1. kuma-sidecar: PodRedirect in file pkg/transparentproxy/kubernetes/kubernetes.go
    2. kuma-cni: NewIntermediateConfig in file app/cni/pkg/cni/annotations_linux.go

@jijiechen
Copy link
Member Author

The PR also includes some minor/revelant refactorings.

Here are some of them:

  1. Removed Probes to be on dataplane objects sinec we don't generate an insecure listener for the virtual probes server any more. So I removed this field and its message definition.
  2. Removed grpc health check proto files from the repo and use the package from GitHub since it was included in the testserver package previously and if I introduce the same proto into a package under kuma-dp, it will generate a conflict panic.
  3. Added the capabilities of supporting scheme and httpHeaders for HTTP probes, supporting of timeout is added for all three kinds of probes.

@jijiechen jijiechen requested review from lukidzi and lobkovilya and removed request for lukidzi July 12, 2024 03:40
@jijiechen jijiechen requested a review from lukidzi July 16, 2024 06:38
// /grpc/<port>
// /<port>/<original-path-query>

if strings.HasPrefix(req.URL.Path, pathPrefixTCP) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use http.NewServeMux() like we do for example here:

mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)

instead of parsing the Path.

@lobkovilya
Copy link
Contributor

@jijiechen please also think about the case when old kuma-dp connects to the new kuma-cp, I believe it won't work because you removed probe_generator.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/run-full-matrix PR: Runs all possible e2e test combination (expensive use carefully)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support TCP and grpc liveness probes
4 participants