You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/kubernetes.rst
+89-15Lines changed: 89 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -179,8 +179,21 @@ The following examples show how to set up a route that will work in Kubernetes.
179
179
The most important thing is the ``ServiceName`` which is made up of the Kubernetes service name.
180
180
We also need to set up the ``ServiceDiscoveryProvider`` in ``GlobalConfiguration``.
181
181
182
+
Regarding global and route configurations, if your downstream service resides in a different namespace, you can override the global setting at the route level by specifying a ``ServiceNamespace``.
183
+
184
+
.. code-block:: json
185
+
186
+
"Routes": [
187
+
{
188
+
"ServiceName": "my-service",
189
+
"ServiceNamespace": "my-namespace"
190
+
}
191
+
]
192
+
193
+
.. _k8s-kube-provider:
194
+
182
195
``Kube`` provider
183
-
^^^^^^^^^^^^^^^^^
196
+
-----------------
184
197
185
198
The example here shows a typical configuration:
186
199
@@ -203,7 +216,7 @@ The example here shows a typical configuration:
203
216
}
204
217
}
205
218
206
-
Service deployment in ``Dev`` namespace, and discovery provider type is ``Kube``, you also can set :ref:`k8s-pollkube-provider` type.
219
+
Service deployment in ``Dev`` namespace, and discovery provider type is ``Kube``, you also can set :ref:`k8s-pollkube-provider` or :ref:`k8s-watchkube-provider` type.
207
220
208
221
**Note 1**: ``Scheme``, ``Host``, ``Port``, and ``Token`` are not used if ``usePodServiceAccount`` is true when `KubeClient`_ is created from a pod service account.
209
222
Please refer to the :ref:`k8s-install` section for technical details.
@@ -215,7 +228,7 @@ Service deployment in ``Dev`` namespace, and discovery provider type is ``Kube``
215
228
.. _k8s-pollkube-provider:
216
229
217
230
``PollKube`` provider
218
-
^^^^^^^^^^^^^^^^^^^^^
231
+
---------------------
219
232
220
233
You use Ocelot to poll Kubernetes for latest service information rather than per request.
221
234
If you want to poll Kubernetes for the latest services rather than per request (default behaviour) then you need to set the following configuration:
@@ -236,23 +249,81 @@ The polling interval is in milliseconds and tells Ocelot how often to call Kuber
236
249
We doubt it will matter for most people and polling may give a tiny performance improvement over calling Kubernetes per request.
237
250
There is no way for Ocelot to work these out for you, except perhaps through a `discussion <https://github.com/ThreeMammals/Ocelot/discussions>`_.
238
251
239
-
Global vs Route levels
240
-
^^^^^^^^^^^^^^^^^^^^^^
252
+
.. _k8s-watchkube-provider:
241
253
242
-
If your downstream service resides in a different namespace, you can override the global setting at the route-level by specifying a ``ServiceNamespace``:
With this configuration, `Kubernetes API`_ "`watch requests`_" are used to fetch service configuration.
260
+
Essentially, it establishes one streamed HTTP connection with the `Kubernetes API`_ per downstream service.
261
+
Changes streamed through this connection will be used to update the list of available endpoints.
243
262
244
263
.. code-block:: json
245
264
246
-
"Routes": [
247
-
{
248
-
"ServiceName": "my-service",
249
-
"ServiceNamespace": "my-namespace"
250
-
}
251
-
]
265
+
"ServiceDiscoveryProvider": {
266
+
"Namespace": "dev",
267
+
"Type": "WatchKube"
268
+
}
269
+
270
+
The provider has an implicit configuration for fine-tuned watching, which are available and can only be initialized in C# code.
271
+
272
+
* ``WatchKube.FirstResultsFetchingTimeoutSeconds``: `This <https://github.com/search?q=repo%3AThreeMammals%2FOcelot%20FirstResultsFetchingTimeoutSeconds&type=code>`_ is the default number of seconds to wait after Ocelot starts, following the provider's creation, to fetch the first result from the Kubernetes endpoint. :sup:`1`
273
+
* ``WatchKube.FailedSubscriptionRetrySeconds``: `This <https://github.com/search?q=repo%3AThreeMammals%2FOcelot%20FailedSubscriptionRetrySeconds&type=code>`__ is the default number of seconds to wait before scheduling the next retry for the subscription operation. :sup:`1`
274
+
275
+
.. _break3: http://break.do
276
+
277
+
**Note 1**: For both ``static int`` properties, the default value is 1 (one) second. The constraint ensures that the assigned value is greater than or equal to 1 (one). Therefore, the minimum value is 1 (one) second.
278
+
279
+
**Note 2**: The ``WatchKube`` provider is specifically designed for high-load Ocelot vs. Kubernetes environments with high RPS ratios.
280
+
To better understand which type is suitable for your needs, we have added a table :ref:`k8s-comparing-providers`.
281
+
282
+
.. _k8s-comparing-providers:
283
+
284
+
Comparing providers
285
+
-------------------
286
+
This table explains the most important indicators that may influence Ocelot vs. Kubernetes deployment or DevOps strategy.
287
+
The evolution path of all providers follows: ``Kube`` -> ``PollKube`` -> ``WatchKube``, with ``WatchKube`` being the most advanced provider.
288
+
289
+
.. list-table::
290
+
:widths: 34 22 22 22
291
+
:header-rows: 1
292
+
293
+
* - *Indicators \\ Providers*
294
+
- :ref:`Kube <k8s-kube-provider>`
295
+
- :ref:`PollKube <k8s-pollkube-provider>`
296
+
- :ref:`WatchKube <k8s-watchkube-provider>`
297
+
* - Extra latency
298
+
- One hop per route
299
+
- \-
300
+
- \-
301
+
* - Speed of response to endpoints changes
302
+
- High
303
+
- Low :sup:`1`
304
+
- High
305
+
* - Pressure on `Kubernetes API`_
306
+
- High
307
+
- Low :sup:`1`
308
+
- Low
309
+
* - Ocelot load (estimated) :sup:`2`
310
+
- < 1000 RPS
311
+
- > 1000 RPS
312
+
- > 5000 RPS
313
+
* - Ocelot deployment :sup:`3`
314
+
- Single instance
315
+
- Multiple instances
316
+
- Cluster of instances
317
+
318
+
.. _break4: http://break.do
319
+
320
+
|:sup:`1` Depends on the ``PollingInterval`` option.
321
+
|:sup:`2` Please consider this a rough load estimation, as our team has not provided any tests or benchmarks.
322
+
|:sup:`3` The term "instance" refers to an Ocelot instance, not a Kubernetes one.
252
323
253
324
.. _k8s-downstream-scheme-vs-port-names:
254
325
255
-
Downstream Scheme vs Port Names [#f3]_
326
+
Downstream Scheme vs Port Names [#f4]_
256
327
--------------------------------------
257
328
258
329
Kubernetes configuration permits the definition of multiple ports with names for each address of an endpoint subset.
@@ -286,7 +357,7 @@ you must define ``DownstreamScheme`` to enable the provider to recognize the des
286
357
}
287
358
]
288
359
289
-
.. _break3: http://break.do
360
+
.. _break5: http://break.do
290
361
291
362
**Note**: In the absence of a specified ``DownstreamScheme`` (which is the default behavior), the ``Kube`` provider will select **the first available port** from the ``EndpointSubsetV1.Ports`` collection.
292
363
Consequently, if the port name is not designated, the default downstream scheme utilized will be ``http``.
@@ -295,13 +366,16 @@ you must define ``DownstreamScheme`` to enable the provider to recognize the des
295
366
296
367
.. [#f1] The :doc:`../features/kubernetes` feature was requested as part of issue `345`_ to add support for `Kubernetes <https://kubernetes.io/>`_ :doc:`../features/servicediscovery` provider, and released in version `13.4.1`_
297
368
.. [#f2] The :ref:`k8s-addkubernetes-action-method` was requested as part of issue `2255`_ (PR `2257`_), and released in version `24.0`_
298
-
.. [#f3] The :ref:`k8s-downstream-scheme-vs-port-names` feature was requested as part of issue `1967`_ and released in version `23.3`_
369
+
.. [#f3] The :ref:`k8s-watchkube-provider` was discussed in thread `2168`_ and released in version `24.1`_
370
+
.. [#f4] The :ref:`k8s-downstream-scheme-vs-port-names` feature was requested as part of issue `1967`_ and released in version `23.3`_
0 commit comments