kuma - exposing your application to the external world
To expose your application to the world, let use the demo app given by Kong/Kuma. This means we don't need to do port forward to post a payload to our app here. We can do it via localhost.
Run the following command. I assume you have installed your kuma control plane.
To install the demo app.
kubectl apply -f https://raw.githubusercontent.com/kumahq/kuma-counter-demo/refs/heads/main/k8s/000-with-kuma.yaml
Once you have installed it, then please the following so we can see the layout:
kubectl port-forward svc/demo-app -n kuma-demo 5050:5050
The demo app should just look like this
Let's expose it to the external world now via port 80 and not 8080 as specified in the documentation. we can do that by creating MeshGatewayInstance, MeshGateway and MeshHttpRoute. We are also creating the MeshTrafficPermission here.
Run the following yaml.
---
apiVersion: kuma.io/v1alpha1
kind: MeshGatewayInstance
metadata:
name: edge-gateway
namespace: kuma-demo
spec:
replicas: 1
serviceType: LoadBalancer
---
apiVersion: kuma.io/v1alpha1
kind: MeshGateway
mesh: default
metadata:
name: edge-gateway
namespace: kuma-demo
spec:
conf:
listeners:
- port: 80
protocol: HTTP
selectors:
- match:
kuma.io/service: edge-gateway_kuma-demo_svc
---
apiVersion: kuma.io/v1alpha1
kind: MeshHTTPRoute
metadata:
name: demo-app-edge-gateway
namespace: kuma-system
spec:
targetRef:
kind: MeshGateway
name: edge-gateway
to:
- targetRef:
kind: Mesh
rules:
- default:
backendRefs:
- kind: MeshService
name: demo-app
namespace: kuma-demo
port: 5050
matches:
- path:
type: PathPrefix
value: /
---
apiVersion: kuma.io/v1alpha1
kind: MeshTrafficPermission
metadata:
namespace: kuma-demo
name: demo-app
spec:
targetRef:
kind: Dataplane
labels:
app: demo-app
from:
- targetRef:
kind: MeshSubset
tags:
kuma.io/service: edge-gateway_kuma-demo_svc
default:
action: Allow
You will see that we have an additional pod call edge-gateway.
Then try to discover the service load balancer IP address. Since i am using Docker desktop, it will be localhost.
Once I have those resource created, I can just run
Comments