|
1 |
| -# auth-gateway |
| 1 | +<p align="center"><img src="images/logo.png" alt="auth-gateway Logo"></p> |
| 2 | + |
| 3 | +[](https://github.com/cortexproject/auth-gateway/actions) |
| 4 | +[](https://godoc.org/github.com/cortexproject/auth-gateway) |
| 5 | +<a href="https://goreportcard.com/report/github.com/cortexproject/auth-gateway"><img src="https://goreportcard.com/badge/github.com/cortexproject/auth-gateway" alt="Go Report Card" /></a> |
| 6 | +<a href="https://cloud-native.slack.com/messages/cortex/"><img src="https://img.shields.io/badge/join%20slack-%23cortex-brightgreen.svg" alt="Slack" /></a> |
| 7 | +<!-- <a href="https://bestpractices.coreinfrastructure.org/projects/6681"><img src="https://bestpractices.coreinfrastructure.org/projects/6681/badge"></a> --> |
| 8 | + |
| 9 | +# auth-gateway: Microservice that helps you debugistrating and operating your [Cortex](https://github.com/cortexproject/cortex) cluster in multi-tenant environments |
| 10 | + |
| 11 | +`auth-gateway` is an entry point for all requests towards Cortex. |
| 12 | +This gateway is responsible for handling multi-tenancy features without complicated proxy configuration. |
| 13 | + |
| 14 | +## What problem does `auth-gateway` solve? |
| 15 | + |
| 16 | +When operating Cortex with numerous tenants, it's crucial to distinguish your tenants each time they make requests to a specific component. |
| 17 | +This differentiation is essential to ensure that each component processes its own requests independently. |
| 18 | + |
| 19 | +To achieve this, Cortex microservices necessitate the inclusion of a header named `X-Scope-OrgID` in each request. |
| 20 | +According to the Cortex Kubernetes (k8s) manifests, it's recommended to implement an NGINX server (eg. [nginx-config.yaml](https://github.com/cortexproject/cortex-helm-chart/blob/master/templates/nginx/nginx-config.yaml)) within each tenant's infrastructure, serving as a reverse proxy. |
| 21 | + |
| 22 | +The primary function of this server is to route the traffic and establish the `X-Scope-OrgID` header for the corresponding tenant |
| 23 | +However, setting up an NGINX server for each tenant is complex and has limitations. |
| 24 | +For instance, you cannot define custom timeouts separately for each tenant. |
| 25 | + |
| 26 | +So, we created `auth-gateway`, a microservice that helps you debugistrating and operating your Cortex cluster in multi-tenant environments with just a simple configuration. |
| 27 | + |
| 28 | +[//]: <> (diagram url -> https://viewer.diagrams.net/?tags=%7B%7D&highlight=0000ff&edit=_blank&layers=1&nav=1&title=#R7V1pd6o6F%2F41Xeu%2BH8piHj461I6eDh572vvlLMSIVCSWwaG%2F%2Fk0QrCSpIkWLve096yoBI%2B797J09hhOpMZ6f%2B%2BZk2IZ94J6IfH9%2BIjVPRFGQZBW94JFFMqLhQzxi%2B04%2FGXsf6DhvIBnkk9HI6YMgc2EIoRs6k%2BygBT0PWGFmzPR9OMteNoBu9lsnpg2ogY5luvToH6cfDpNRgeffT1wAxx4mX60ryYmxmV6cDARDsw9na0PS2YnU8CEMl%2B%2FG8wZwMfVSuiw%2F1%2Frg7OrGfOCFeT5gv9mP9ftLf6h2W%2FB5Lrhv0%2BtTSVpOMzXdKPnFyd2Gi5QEaBpEbXRQRz9hggctF0Zo1vps6ISgMzEtPDhDCEBjw3DsoiMBXz4CoYWJwONx0xpGPjjHFzVlNPDi2Hb8FYgS9QH0wpY5dlyMkwYcOxa6h47pBeil3UkuSNAhqOiY%2FvUJQabAD8F8bSihxjmAYxD6C3RJgsXTFGOzNcbqydhwjaeCnAyaCZjs1Vzv9EZvEpKzyT%2F1vLO%2BaV8rjt7RBOO8PZpEp5qcg%2Fxev4aBHNPdDAJEmgyVfRh5fdBPjkg6gbkTPiXn8PvnhB34fXO%2BfrBIDzz0y57WD%2BLPcKqgpAPvH4yP0k%2F2zWC4upEg9OEINKAL%2Ffh3SPX4v9WZVJrEdJo74DuIqsBPZtsKiRW8hE14CGDkW2ADD1Q9USumb4Nw04XL60A%2FozFoeK3BSWGgKR3zgWuGzjSrZ1gIS77hDjrop4l8im0tmSdBsygRIF3%2B8ORT63qBmEg2shNJkpKdaEkYaiIESnOxdtkEXxBQIrEiTHEpSSX7XUiaDgKR04tCBC5SXrLysEVFkeJSEuhyKKHkrCgTbOQZSklkwGhvOoleEe4jEN9yy0fUQeqoXJJntMbB6a%2BKVaM%2FvSRcejYIsGL8X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4uSWu6y9hT%2FCJdYKoCh%2FoPHERdVDk9G9BmFEyUhAh06EPMi3d9gvcVacM%2B1vRn%2Fwc%3D) |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +## Features |
| 33 | + |
| 34 | +* Enabling multi-tenancy feature of Cortex with just a simple configuration |
| 35 | +* Supporting HTTP basic authentication |
| 36 | +* Defining custom timeouts for each of your components |
| 37 | +* Load balancing |
| 38 | + |
| 39 | +## Configuration |
| 40 | + |
| 41 | +### Generic Placeholders |
| 42 | + |
| 43 | +* `<int>`: any integer matching the regular expression [1-9]+[0-9]* |
| 44 | +* `<duration>`: a duration matching the regular expression [0-9]+(ns|us|µs|ms|s|m|h|d|w|y) where y = 365 days. |
| 45 | +* `<string>`: a regular string |
| 46 | +* `<url>`: a URL |
| 47 | + |
| 48 | +```yaml |
| 49 | + |
| 50 | +# The main server that auth-gateway will listen on. Any request that comes to this server will be forwarded to the corresponding component. Requires authentication. |
| 51 | +server: <server_config> |
| 52 | + |
| 53 | +# A supporting server that exposes metrics, ready and pprof endpoints. Does not require authentication. |
| 54 | +debug: <server_config> |
| 55 | + |
| 56 | +# List of all tenants that auth-gateway will serve. |
| 57 | +tenants: <tenant_config> |
| 58 | + |
| 59 | +distributor: <component_config> |
| 60 | + |
| 61 | +frontend: <component_config> |
| 62 | + |
| 63 | +alertmanager: <component_config> |
| 64 | + |
| 65 | +ruler: <component_config> |
| 66 | + |
| 67 | +``` |
| 68 | +
|
| 69 | +### server_config |
| 70 | +
|
| 71 | +The `server_config` configures the servers. |
| 72 | + |
| 73 | +```yaml |
| 74 | +
|
| 75 | +# hostname or IP address that auth-gateway will listen on, not a url |
| 76 | +address: <string> |
| 77 | +port: <int> |
| 78 | +http_server_read_timeout: <duration> | default = 30s |
| 79 | +http_server_write_timeout: <duration> | default = 30s |
| 80 | +http_server_idle_timeout: <duration> | default = 120s |
| 81 | +
|
| 82 | +``` |
| 83 | + |
| 84 | +### tenant_config |
| 85 | + |
| 86 | +The `tenant_config` configures the tenants. |
| 87 | + |
| 88 | +```yaml |
| 89 | +
|
| 90 | +- authentication: basic |
| 91 | + username: <string> |
| 92 | + password: <string> |
| 93 | + id: <string> |
| 94 | +- ... # more tenants |
| 95 | +
|
| 96 | +``` |
| 97 | + |
| 98 | +### component_config |
| 99 | +The `component_config` configures the components. |
| 100 | +Although the default timeout values are defined below, these default values differ depending on the component. |
| 101 | +To learn each component's timeout values, please refer to the [default timeout values](#default_timeout_values) section. |
| 102 | + |
| 103 | +```yaml |
| 104 | +
|
| 105 | +url: <url> |
| 106 | + dns_refresh_interval: <duration> | default = 1s |
| 107 | + paths: |
| 108 | + - <string> |
| 109 | + - <string> |
| 110 | + http_client_timeout: <duration> | default = 15s |
| 111 | + http_client_dialer_timeout: <duration> | default = 5s |
| 112 | + http_client_tls_handshake_timeout: <duration> | default = 5s |
| 113 | + http_client_response_header_timeout: <duration> | default = 5s |
| 114 | +
|
| 115 | +``` |
| 116 | + |
| 117 | +### <a name="default_timeout_values"></a> Default Timeout Values |
| 118 | + |
| 119 | +Each component in the `component_config` has different default timeout values. |
| 120 | +They are as follows: |
| 121 | + |
| 122 | +| Component | `http_client_timeout` | `http_client_dialer_timeout` | `http_client_tls_handshake_timeout` | `http_client_response_header_timeout` | |
| 123 | +| ------------ | --------------------- | ---------------------------- | ----------------------------------- | ------------------------------------- | |
| 124 | +| Distributor | 15s | 5s | 5s | 5s | |
| 125 | +| Frontend | 1m | 5s | 5s | 5s | |
| 126 | +| Alertmanager | 15s | 5s | 5s | 5s | |
| 127 | +| Ruler | 15s | 5s | 5s | 5s | |
| 128 | + |
| 129 | +You can override these default values by specifying your desired timeout values in the `component_config` for each component. |
| 130 | + |
| 131 | +## Contributing |
| 132 | + |
| 133 | +We welcome contributions. |
| 134 | +Please follow the [contributing guidelines](CONTRIBUTING.md). |
| 135 | + |
| 136 | +## <a name="help"></a> Getting Help |
| 137 | + |
| 138 | +If you have any questions about `auth-gateway`: |
| 139 | + |
| 140 | +- Ask a question on the [Cortex Slack channel](https://cloud-native.slack.com/messages/cortex/). |
| 141 | +To invite yourself to the CNCF Slack, visit http://slack.cncf.io/. |
| 142 | +- <a href="https://github.com/cortexproject/auth-gateway/issues/new">File an issue.</a> |
| 143 | +- Send an email to <a href="mailto:[email protected]">[email protected]</a> |
| 144 | + |
| 145 | +Your feedback is always welcomed! |
0 commit comments