このページは、まだ日本語ではご利用いただけません。翻訳中です。
Services and Routes
A Service inside Kubernetes is a way to abstract an application that is running on a set of Pods. This maps to two objects in Kong: Service and Upstream.
The service object in Kong holds the information of the protocol to use to talk to the upstream service and various other protocol specific settings. The Upstream object defines load-balancing and health-checking behavior.
flowchart LR H(Request traffic) subgraph Pods direction LR E(Target) F(Target) G(Target) end subgraph Kubernetes Service direction TB C(Service) D(Upstream) end subgraph Ingress rules direction LR A(Route) B(Route) end A --> C B --> C C --> D D --> E D --> F D --> G H --> A classDef lightBlue fill:#cce7ff; classDef lightGreen fill:#c4e1c4; classDef lightPurple fill:#e6d8eb; classDef lightGrey fill:#f5f5f5; class A,B lightGreen; class C lightBlue; class D lightPurple; class E,F,G lightGrey; linkStyle 6 stroke:#b6d7a8
Routes are configured using Gateway API or Ingress resources, such as HTTPRoute
, TCPRoute
, GRPCRoute
, Ingress
and more.
In this tutorial, you will deploy an echo
service which returns information about the Kubernetes cluster and route traffic to the service.
Deploy an echo service
To proxy requests, you need an upstream application to send a request to. Deploying this echo server provides a simple application that returns information about the Pod it’s running in:
kubectl apply -f https://docs.jp.konghq.com/assets/kubernetes-ingress-controller/examples/echo-service.yaml
The results should look like this:
service/echo created
deployment.apps/echo created
Add routing configuration
Create routing configuration to proxy /echo
requests to the echo server:
The results should look like this:
Test the routing rule:
curl -i $PROXY_IP/echo
The results should look like this:
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 140
Connection: keep-alive
Date: Fri, 21 Apr 2023 12:24:55 GMT
X-Kong-Upstream-Latency: 0
X-Kong-Proxy-Latency: 1
Via: kong/3.2.2
Welcome, you are connected to node docker-desktop.
Running on Pod echo-7f87468b8c-tzzv6.
In namespace default.
With IP address 10.1.0.237.
...
If everything is deployed correctly, you should see the above response. This verifies that Kong Gateway can correctly route traffic to an application running inside Kubernetes.