|
| 1 | +# Starting feast servers in TLS (SSL) mode. |
| 2 | +TLS (Transport Layer Security) and SSL (Secure Sockets Layer) are both protocols encrypts communications between a client and server to provide enhanced security.TLS or SSL words used interchangeably. |
| 3 | +This article is going to show the sample code to start all the feast servers such as online server, offline server, registry server and UI server in TLS mode. |
| 4 | +Also show examples related to feast clients to communicate with the feast servers started in TLS mode. |
| 5 | + |
| 6 | +## Obtaining a self-signed TLS certificate and key |
| 7 | +In development mode we can generate a self-signed certificate for testing. In an actual production environment it is always recommended to get it from a trusted TLS certificate provider. |
| 8 | + |
| 9 | +```shell |
| 10 | +openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes |
| 11 | +``` |
| 12 | + |
| 13 | +The above command will generate two files |
| 14 | +* `key.pem` : certificate private key |
| 15 | +* `cert.pem`: certificate public key |
| 16 | + |
| 17 | +You can use the public or private keys generated from above command in the rest of the sections in this tutorial. |
| 18 | + |
| 19 | +## Create the feast demo repo for the rest of the sections. |
| 20 | +create a feast repo using `feast init` command and use this repo as a demo for subsequent sections. |
| 21 | + |
| 22 | +```shell |
| 23 | +feast init feast_repo_ssl_demo |
| 24 | +``` |
| 25 | + |
| 26 | +Output is |
| 27 | +``` |
| 28 | +Creating a new Feast repository in /Documents/Src/feast/feast_repo_ssl_demo. |
| 29 | +``` |
| 30 | + |
| 31 | +You need to execute the feast cli commands from `feast_repo_ssl_demo/feature_repo` directory created from the above `feast init` command. |
| 32 | + |
| 33 | +## Starting feast online server (feature server) in TLS mode |
| 34 | +To start the feature server in TLS mode, you need to provide the private and public keys using the `--key` and `--cert` arguments with the `feast serve` command. |
| 35 | + |
| 36 | +```shell |
| 37 | +feast serve --key /path/to/key.pem --cert /path/to/cert.pem |
| 38 | +``` |
| 39 | +You will see the output something similar to as below. Note the server url starts in the `https` mode. |
| 40 | + |
| 41 | +```shell |
| 42 | +[2024-11-04 15:03:57 -0500] [77989] [INFO] Starting gunicorn 23.0.0 |
| 43 | +[2024-11-04 15:03:57 -0500] [77989] [INFO] Listening at: https://127.0.0.1:6566 (77989) |
| 44 | +[2024-11-04 15:03:57 -0500] [77989] [INFO] Using worker: uvicorn_worker.UvicornWorker |
| 45 | +[2024-11-04 15:03:57 -0500] [77992] [INFO] Booting worker with pid: 77992 |
| 46 | +[2024-11-04 15:03:57 -0500] [77992] [INFO] Started server process [77992] |
| 47 | +[2024-11-04 15:03:57 -0500] [77992] [INFO] Waiting for application startup. |
| 48 | +[2024-11-04 15:03:57 -0500] [77992] [INFO] Application startup complete. |
| 49 | +``` |
| 50 | + |
| 51 | + |
| 52 | +### Feast client connecting to remote online sever started in TLS mode. |
| 53 | + |
| 54 | +Sometimes you may need to pass the self-signed public key to connect to the remote online server started in SSL mode if you have not added the public key to the certificate store. |
| 55 | + |
| 56 | +feast client example: |
| 57 | +The registry is pointing to registry of remote feature store. If it is not accessible then should be configured to use remote registry. |
| 58 | + |
| 59 | +```yaml |
| 60 | +project: feast-project |
| 61 | +registry: /remote/data/registry.db |
| 62 | +provider: local |
| 63 | +online_store: |
| 64 | + path: http://localhost:6566 |
| 65 | + type: remote |
| 66 | + cert: /path/to/cert.pem |
| 67 | +entity_key_serialization_version: 2 |
| 68 | +auth: |
| 69 | + type: no_auth |
| 70 | +``` |
| 71 | +{% endcode %} |
| 72 | +
|
| 73 | +`cert` is an optional configuration to the public certificate path when the online server starts in TLS(SSL) mode. Typically, this file ends with `*.crt`, `*.cer`, or `*.pem`. |
| 74 | + |
| 75 | +## Starting feast Registry server in TLS mode |
| 76 | +To start the feature server in TLS mode, you need to provide the private and public keys using the `--key` and `--cert` arguments with the `feast serve_registry` command. |
| 77 | + |
| 78 | +```shell |
| 79 | +feast serve_registry --key /path/to/key.pem --cert /path/to/cert.pem |
| 80 | +``` |
| 81 | +You will see the output something similar to as below. Note the server url starts in the `https` mode. |
| 82 | + |
| 83 | +```shell |
| 84 | +11/04/2024 03:10:27 PM feast.registry_server INFO: Starting grpc registry server in TLS(SSL) mode |
| 85 | +11/04/2024 03:10:27 PM feast.registry_server INFO: Grpc server started at https://localhost:6570 |
| 86 | +``` |
| 87 | + |
| 88 | +### Feast client connecting to remote registry sever started in TLS mode. |
| 89 | + |
| 90 | +Sometimes you may need to pass the self-signed public key to connect to the remote registry server started in SSL mode if you have not added the public key to the certificate store. |
| 91 | + |
| 92 | +feast client example: |
| 93 | + |
| 94 | +```yaml |
| 95 | +project: feast-project |
| 96 | +registry: |
| 97 | + registry_type: remote |
| 98 | + path: https://localhost:6570 |
| 99 | + cert: /path/to/cert.pem |
| 100 | +provider: local |
| 101 | +online_store: |
| 102 | + path: http://localhost:6566 |
| 103 | + type: remote |
| 104 | + cert: /path/to/cert.pem |
| 105 | +entity_key_serialization_version: 2 |
| 106 | +auth: |
| 107 | + type: no_auth |
| 108 | +``` |
| 109 | +{% endcode %} |
| 110 | + |
| 111 | +`cert` is an optional configuration to the public certificate path when the registry server starts in TLS(SSL) mode. Typically, this file ends with `*.crt`, `*.cer`, or `*.pem`. |
| 112 | + |
| 113 | +## Starting feast offline server in TLS mode |
| 114 | + |
| 115 | +TBD |
| 116 | + |
| 117 | + |
| 118 | +## Starting feast UI server (react app) in TLS mode |
| 119 | +To start the feast UI server in TLS mode, you need to provide the private and public keys using the `--key` and `--cert` arguments with the `feast ui` command. |
| 120 | + |
| 121 | +```shell |
| 122 | +feast ui --key /path/to/key.pem --cert /path/to/cert.pem |
| 123 | +``` |
| 124 | +You will see the output something similar to as below. Note the server url starts in the `https` mode. |
| 125 | + |
| 126 | +```shell |
| 127 | +INFO: Started server process [78872] |
| 128 | +INFO: Waiting for application startup. |
| 129 | +INFO: Application startup complete. |
| 130 | +INFO: Uvicorn running on https://0.0.0.0:8888 (Press CTRL+C to quit) |
| 131 | +``` |
0 commit comments