From 635c293a6d0368115cc2aa609f12b24f11e63208 Mon Sep 17 00:00:00 2001 From: geffzhang Date: Tue, 29 Jan 2019 12:41:46 +0800 Subject: [PATCH] feat :add kubetnetes docs how to use ocelot with kubetnetes docs --- docs/features/kubernetes.rst | 56 ++++++++++++++++++++++++++++++++++++ docs/index.rst | 3 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 docs/features/kubernetes.rst diff --git a/docs/features/kubernetes.rst b/docs/features/kubernetes.rst new file mode 100644 index 00000000..30b57a9b --- /dev/null +++ b/docs/features/kubernetes.rst @@ -0,0 +1,56 @@ +Kubernetes +============== + +This feature was requested as part of `Issue 345 `_ . to add support for kubernetes's service discovery provider. + +The first thing you need to do is install the NuGet package that provides kubernetes support in Ocelot. + +``Install-Package Ocelot.Provider.Kubernetes`` + +Then add the following to your ConfigureServices method. + +.. code-block:: csharp + + s.AddOcelot() + .AddKubernetes(); + +If you have services deployed in kubernetes you will normally use the naming service to access them. + +The following example shows how to set up a ReRoute that will work in kubernetes. The most important thing is the ServiceName which is made up of the +kubernetes service name. We also need to set up the ServiceDiscoveryProvider in +GlobalConfiguration. The example here shows a typical configuration. It assumes kubernetes api server is running on 192.168.0.13 and that the api service is on port 443. + +The example below is taken from the samples folder so please check it if this doesnt make sense! + +.. code-block:: json + + { + "ReRoutes": [ + { + "DownstreamPathTemplate": "/api/values", + "DownstreamScheme": "http", + "UpstreamPathTemplate": "/values", + "ServiceName": "downstreamservice", + "UpstreamHttpMethod": [ "Get" ], + "QoSOptions": { + "ExceptionsAllowedBeforeBreaking": 3, + "DurationOfBreak": 10000, + "TimeoutValue": 5000 + }, + "FileCacheOptions": { "TtlSeconds": 15 } + } + ], + "GlobalConfiguration": { + "RequestIdKey": "OcRequestId", + "AdministrationPath": "/administration", + "ServiceDiscoveryProvider": { + "Host": "192.168.0.13", + "Port": 443, + "Token": "txpc696iUhbVoudg164r93CxDTrKRVWG", + "Namespace": "dev", + "Type": "kube" + } + } +} + +There is no way for Ocelot to work these out for you. diff --git a/docs/index.rst b/docs/index.rst index 7989fcdd..4aba33fd 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,7 +23,8 @@ Thanks for taking a look at the Ocelot documentation. Please use the left hand n features/requestaggregation features/graphql features/servicediscovery - features/servicefabric + features/servicefabric + features/kubernetes features/authentication features/authorisation features/websockets