|
2 | 2 |
|
3 | 3 | > Disclaimer: ChrisB to refine when back home.
|
4 | 4 |
|
5 |
| -Prereqs: |
6 |
| -- have a local kind cluster running and working, and running an MCP server with the proxy workload fronting it |
| 5 | +Prerequisites: |
| 6 | +- Have a local Kind Cluster running |
| 7 | +- Have an MCP server with the proxy workload fronting it (this can be achieved by running the `test-k8s-apply` Taskfile task. `task test-k8s-apply`) |
7 | 8 |
|
8 |
| -Run the local Kind Go binary that acts as a small LoadBalancer that gives IPs to ingress controllers inside of the cluster. This mimicks the behaviour of Cloud LBs |
| 9 | +There should now be a local Kind cluster with an MCP server running and a ToolHive proxy running, in addition to an Nginx Ingress controller running and pending an ExternalIP. |
| 10 | + |
| 11 | +To give the ingress controller an IP, we will run a local Kind Go binary that acts as a small LoadBalancer that gives IPs to ingress controllers inside of the Kind Cluster. This binary mimicks Cloud Providers LoadBalancers functionality for local Kind setups. |
9 | 12 |
|
10 | 13 | ```
|
11 | 14 | go install sigs.k8s.io/cloud-provider-kind@latest
|
12 | 15 | sudo ~/go/bin/cloud-provider-kind
|
13 | 16 | ```
|
14 | 17 |
|
15 |
| -Install the Nginx controller |
16 |
| -``` |
17 |
| -kubectl apply -f https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx.yaml |
18 |
| -``` |
19 |
| - |
20 |
| -When the ingress controller is running, you should have an external IP set for it. Take not of this IP. |
21 |
| - |
22 |
| -Add the following Ingress yaml that points to your toolhive service: |
23 |
| -```yaml |
24 |
| ---- |
25 |
| -apiVersion: networking.k8s.io/v1 |
26 |
| -kind: Ingress |
27 |
| -metadata: |
28 |
| - name: example-ingress |
29 |
| -spec: |
30 |
| - ingressClassName: nginx |
31 |
| - rules: |
32 |
| - - http: |
33 |
| - paths: |
34 |
| - - pathType: Prefix |
35 |
| - path: /sse |
36 |
| - backend: |
37 |
| - service: |
38 |
| - name: toolhive |
39 |
| - port: |
40 |
| - number: 8080 |
41 |
| - - pathType: Prefix |
42 |
| - path: /messages |
43 |
| - backend: |
44 |
| - service: |
45 |
| - name: toolhive |
46 |
| - port: |
47 |
| - number: 8080 |
48 |
| -``` |
49 |
| -
|
50 |
| -Now, you _should_ be able to curl the endpoint via `curl http://$EXTERNAL_IP/sse` and see a connection. |
51 |
| - |
52 |
| -## Chris To Do |
53 |
| -- adds the docs for the addition of a host name to make it look more ingressy, this avoids the IP requirement.g |
| 18 | +After a few moments, the ingress controller should be running and the service should have an external IP set for it. Run the below to get the IP and store it in a variable, and then curl the MCP server endpoint to see a connection. |
| 19 | + |
| 20 | +``` |
| 21 | +$ LB_IP=$(kubectl get svc/ingress-nginx-controller -n ingress-nginx -o=jsonpath='{.status.loadBalancer.ingress[0].ip}') |
| 22 | +$ curl $LB_IP/sse |
| 23 | +event: endpoint |
| 24 | +data: http://172.20.0.3/messages?session_id=637d766e-354a-45b6-bc91-e153a35bc49f |
| 25 | +``` |
| 26 | + |
| 27 | +## Ingress with Local Hostname |
| 28 | + |
| 29 | +In order to avoid using of the IP you can use a hostname instead of preferred. This can be achieved by modifying the `/etc/hosts` file to include a mapping for the load balancer IP to a friendly hostname. |
| 30 | + |
| 31 | +``` |
| 32 | +sudo sh -c "echo '$LB_IP mcp-server.dev' >> /etc/hosts" |
| 33 | +``` |
| 34 | + |
| 35 | +Now when you curl that endpoint, it should connect as it did with the IP |
| 36 | + |
| 37 | +``` |
| 38 | +$ curl mcp-server.dev/sse |
| 39 | +event: endpoint |
| 40 | +data: http://mcp-server.dev/messages?session_id=337e4d34-5fb0-4ccc-9959-fc382d5b4800 |
| 41 | +``` |
0 commit comments