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

Support mTLS in Elastic Inference Service plugin (#116423) #119679

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

vidok
Copy link
Contributor

@vidok vidok commented Jan 7, 2025

Note: Technically, this PR reverts b357936227df04f88c980b6cbf7cd7cde982a25b.

This PR introduced support for mTLS in the Elastic Inference Service plugin. It uses SSLService to parse, validate the configuration, and create an SSLStrategy that’s used in the HTTPClientManager.

  • Embedded xpack.inference.elastic.http.ssl to SSLService.
  • Extended HTTPClientManager to propagate SSLStrategy to HTTPClientConnectionManager
  • Added the following settings:
xpack.inference.elastic.http.ssl.enable
xpack.inference.elastic.http.ssl.cipher_suites
xpack.inference.elastic.http.ssl.supported_protocols
xpack.inference.elastic.http.ssl.truststore.path
xpack.inference.elastic.http.ssl.truststore.secure_password
xpack.inference.elastic.http.ssl.truststore.algorithm
xpack.inference.elastic.http.ssl.truststore.type
xpack.inference.elastic.http.ssl.trust_restrictions.path
xpack.inference.elastic.http.ssl.trust_restrictions.x509_fields
xpack.inference.elastic.http.ssl.certificate_authorities
xpack.inference.elastic.http.ssl.client_authentication
xpack.inference.elastic.http.ssl.verification_mode
xpack.inference.elastic.http.ssl.truststore.password
xpack.inference.elastic.http.ssl.keystore.path
xpack.inference.elastic.http.ssl.keystore.secure_password
xpack.inference.elastic.http.ssl.keystore.algorithm
xpack.inference.elastic.http.ssl.keystore.type
xpack.inference.elastic.http.ssl.keystore.secure_key_password
xpack.inference.elastic.http.ssl.key
xpack.inference.elastic.http.ssl.secure_key_passphrase
xpack.inference.elastic.http.ssl.certificate
xpack.inference.elastic.http.ssl.keystore.password
xpack.inference.elastic.http.ssl.keystore.key_password
xpack.inference.elastic.http.ssl.key_passphrase

How to test the PR locally?:

Skip certificates validation

  1. Run Elastic Inference Service locally and disable client certificate validate (see the service's documentation).
  2. Build an Elasticsearch snapshot by running ./gradlew localDistro.
  3. Go to build/distribution/local/elasticsearch-x.x.x-SNAPSHOT folder.
  4. Run Elasticsearch with the following command
./bin/elasticsearch -E xpack.inference.elastic.url=https://localhost:8443 -E xpack.inference.elastic.http.ssl.verification_mode=none

Certificates validation

  1. Generate a new set of TLS certificates and run Elastic Inference Service locally (see the service's documentation).
  2. Build an Elasticsearch snapshot by running ./gradlew localDistro.
  3. Go to build/distribution/local/elasticsearch-x.x.x-SNAPSHOT folder.
  4. Copy generated in step 1 tls.key, tis.crt and ca.crt to Elasticsearch snapshot config folder.
  5. Rename ca.crt to ca.pem (it seems unnecessary but ES expects a PEM file).
  6. Run Elasticsearch with the following command (make sure the path to the certificates is correct).
./bin/elasticsearch -E xpack.inference.elastic.url=https://localhost:8443 -E xpack.inference.elastic.http.ssl.certificate=tls/tls.crt -E xpack.inference.elastic.http.ssl.key=tls/tls.key -E xpack.inference.elastic.http.ssl.certificate_authorities=ca/ca.pem

Perform inference requests:

  1. Create an inference endpoint:
PUT {ES_HOST}/_inference/sparse_embedding/eis

{
    "service": "elastic",
    "service_settings": {
        "model_id": ".elser_model_2"
    }
}
  1. Perform an inference request
POST {ES_HOST}/_inference/sparse_embedding/eis

{
    "input": "A blue sky"
}

Follow-up actions:

  • Utilize the same connection eviction manager to reduce the number of used threads.
  • Find a way to use the same connection manager for all external HTTP connections instead of having a dedicated manager for Elastic Inference Service.
  • Add an integration test.

@vidok vidok added >feature :ml Machine learning labels Jan 10, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @vidok, I've created a changelog YAML for you.

@vidok vidok added the v8.18.0 label Jan 10, 2025
@vidok vidok requested a review from timgrein January 10, 2025 11:07
@vidok vidok added the auto-backport Automatically create backport pull requests when merged label Jan 10, 2025
@vidok vidok marked this pull request as ready for review January 10, 2025 11:08
@elasticsearchmachine elasticsearchmachine added the Team:ML Meta label for the ML team label Jan 10, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

vidok and others added 3 commits January 10, 2025 12:38
* Introduce new SSL settings under `xpack.inference.elastic.http.ssl`.

* Support mTLS connection between Elasticsearch and Elastic Inference Service.
@vidok vidok force-pushed the dmitrii/reintroduce-inference-service-mtls branch from 616264d to df50a54 Compare January 10, 2025 11:38
Copy link
Contributor

@slobodanadamovic slobodanadamovic left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged >feature :ml Machine learning Team:ML Meta label for the ML team v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants