A MeshGatewayInstance
configures the pods
that will run the gateway.
Create it by running:
echo "apiVersion: kuma.io/v1alpha1
kind: MeshGatewayInstance
metadata:
name: edge-gateway
namespace: kuma-demo
spec:
replicas: 1
serviceType: LoadBalancer" | kubectl apply -f -
The Kubernetes cluster needs to support LoadBalancer
for this to work.
If you are running minikube
you will want to open a tunnel with minikube tunnel -p mesh-zone
.
You may not have support for LoadBalancer
if you are running locally with kind
or k3d
.
One option for kind
is kubernetes-sigs/cloud-provider-kind may be helpful.
MeshGateway
defines listeners for the gateway.
Define a single HTTP listener on port 8080:
echo "apiVersion: kuma.io/v1alpha1
kind: MeshGateway
mesh: default
metadata:
name: my-gateway
spec:
selectors:
- match:
kuma.io/service: edge-gateway_kuma-demo_svc
conf:
listeners:
- port: 8080
protocol: HTTP
tags:
port: http-8080" | kubectl apply -f -
Notice how the selector selects the kuma.io/service
tag of the previously defined MeshGatewayInstance
.
Now look at the pods running in the namespace by running:
kubectl get pods -n kuma-demo
Observe the gateway pod:
NAME READY STATUS RESTARTS AGE
redis-5fdb98848c-5tw62 2/2 Running 0 5m5s
demo-app-c7cd6588b-rtwlj 2/2 Running 0 5m5s
edge-gateway-66c76fd477-ncsp5 1/1 Running 0 18s
Retrieve the public URL for the gateway with:
export PROXY_IP=$(kubectl get svc --namespace kuma-demo edge-gateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo $PROXY_IP
Check the gateway is running:
Which outputs:
* Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080
> GET / HTTP/1.1ó
> Host: 127.0.0.1:8080
> User-Agent: curl/8.4.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< content-length: 62
< content-type: text/plain
< vary: Accept-Encoding
< date: Fri, 09 Feb 2024 10:07:26 GMT
< server: Kuma Gateway
<
This is a Kuma MeshGateway. No routes match this MeshGateway!
Notice the gateway says that there are no routes configured.