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] proxy implementation #36907

Closed
wants to merge 56 commits into from
Closed

[feat] proxy implementation #36907

wants to merge 56 commits into from

Conversation

toddself
Copy link
Contributor

@toddself toddself commented May 22, 2019

Summary

This is an x-pack plugin to implement a request proxy system for kibana.

This allows parts of kibana to register as the responsible instance for a certain
resource and then allow other kibana instances to discover this information
and proxy requests for that resource back to the responsible instance.

This initial implementation is based around the needs for the code plugin, but
the idea is make this generic enough for use in other parts of the system.

There are a few pending issues:

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

DevDoc

This PR implements an internal proxy mechanism for a collection of Kibana nodes living behind the same load balancer, with a shared mapping for resources stored in the backing Elasticsearch store.

The proxy allows a plugin developer to register resources with specific nodes, and then forward requests for those resources to the responsible nodes, so that the data may be returned to the user requesting it.

The end-user must provide SSL certificates and keys for the server and client to communicate via Mutual TLS authorization, securing any internal data from easily leaking out. If the SSL certificates are self-signed, the signing certificate authority will also need to be provided. Information on generating the keys, certificates and authorities may be found in the Elasticsearch encrypted communications guide. The proxy will throw an error on start if the TLS configuration has not been provided.

This introduces several new configuration options under the xpack.proxy path:

  • updateInterval - the frequency (in ms) that the nodes should verify their availability
  • timeoutThreshold - the maximum length of time (in ms) that a node can go without checking in
  • port - the port number that the proxy server should be listening on
  • maxRetry - the number of times the proxy should attempt to request the remote resource before giving up
  • requestBackoff - how long the proxy should wait before re-requesting an unavailable resource

The following configuration options are the same as from server.ssl:

  • cert - the TLS certificate to use
  • key - the key for this TLS certificate
  • ca - the certificate authority used to generate this certificate
  • cipherSuites - the cipher suites to use
  • supportedProtocols - the protocols supported by the proxy

When instantiated, proxy.setup() returns:

export interface ProxyServiceSetup {
  httpSetup: Omit<HttpServiceSetup, 'createNewServer'>;
}

And proxy.start() returns:

export interface ProxyServiceStart {
  assignResource: (
    resource: string,
    type: string,
    state: RouteState,
    node?: string
  ) => Promise<void>;
  unassignResource: (resource: string) => Promise<void>;
  proxyResource: (resource: string) => (req: KibanaRequest) => Promise<any>;
  proxyRequest: (req: KibanaRequest, resource: string) => Promise<any>;
  getAllocation: () =>Promise<RoutingTable>;
}

@epixa epixa added the Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc label May 22, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@zfy0701 zfy0701 added the :Code label Jun 4, 2019
Copy link
Contributor

@mshustov mshustov left a comment

Choose a reason for hiding this comment

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

probably this PR is not finished yet, so I stop commenting 😅

package.json Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
x-pack/plugins/proxy/server/proxy.ts Outdated Show resolved Hide resolved
x-pack/plugins/proxy/server/proxy_config.ts Outdated Show resolved Hide resolved
x-pack/plugins/proxy/server/proxy.ts Outdated Show resolved Hide resolved
x-pack/plugins/proxy/server/proxy.ts Outdated Show resolved Hide resolved
x-pack/plugins/proxy/server/proxy.ts Outdated Show resolved Hide resolved
x-pack/plugins/proxy/server/proxy.ts Outdated Show resolved Hide resolved
x-pack/plugins/proxy/server/proxy.ts Outdated Show resolved Hide resolved
@toddself
Copy link
Contributor Author

toddself commented Jun 7, 2019

@restrry @dover @spacedragon this is ready for a final review. i'm starting to write tests for it.

@toddself toddself marked this pull request as ready for review June 7, 2019 20:36
Copy link
Contributor

@zfy0701 zfy0701 left a comment

Choose a reason for hiding this comment

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

unless you plan to do it later, otherwise I think last week we agree on implement based on optimistic concurrent control, which means we need to take version query parameter to the request and properly handle it if the update fail

@toddself toddself requested a review from a team as a code owner June 12, 2019 19:56
@toddself toddself force-pushed the proxy branch 4 times, most recently from db7a87b to 7bd4d7c Compare June 14, 2019 20:57
@toddself toddself requested a review from a team as a code owner June 14, 2019 20:57
@toddself toddself added the release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. label Jun 15, 2019
@toddself toddself force-pushed the proxy branch 2 times, most recently from 33922df to 603889e Compare June 17, 2019 18:36
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@spalger
Copy link
Contributor

spalger commented Aug 27, 2019

Closing this for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.3.2 v7.4.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.