Kubernetes App Auto Discovery: improve protocol detection #50223
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Kubernetes App Auto Discovery iterates over all Services and tries to auto enroll them as Teleport Applications.
During this process, it tries to guess the Service's port protocol to ensure we add the application only if it's either an HTTP or HTTPS capable Service.
When there's not annotation configuration (which are teleport specific), we try to infer from the Service's ports.
When that doesn't work out, the teleport-agent issues an HTTP HEAD request against the port. This way we detect whether the service can answer HTTP or HTTPS.
This PR changes the way teleport infers the protocol using the Service's Port.
It was checking for HTTPS (checking for port number and port name), then it did a HTTP HEAD request and then it was checking for HTTP (checking port number and port name).
This PR changes 4 things:
With a demo cluster with 2700+ Services, the reconciliation time decreased from 2m to something very close to 0s.
Demo
A new fetch/reconcile loop happens 5 minutes after the previous finishes.
With master, the reconcile loop happens after 7 minutes, so it's 5 minutes spent waiting for the new iteration and 2 minutes doing fetch/reconcile:
With this PR, the reconcile loop happens almost exactly after 5 minutes, which means less than a second is spent on fetch/reconcile:
changelog: Improve performance of Kubernetes App Auto Discover