By default, the network is insecure and not encrypted. We can change this with Kong Mesh by enabling
the Mutual TLS policy to provision a Certificate Authority (CA) that
will automatically assign TLS certificates to our services (more specifically to the injected data plane proxies running
alongside the services).
We can enable Mutual TLS with a builtin
CA backend by executing:
kubectl patch mesh default --type merge --patch "$(curl https://raw.githubusercontent.com/kumahq/kuma-counter-demo/refs/heads/main/kustomize/overlays/001-with-mtls/mesh.yaml)"
Which will update Mesh config to:
apiVersion: kuma.io/v1alpha1
kind: Mesh
metadata:
name: default
spec:
meshServices:
mode: Exclusive
mtls:
backends:
- name: ca-1
type: builtin
enabledBackend: ca-1
The traffic is now encrypted and secure. Kong Mesh does not define default traffic permissions, which means that no traffic will flow with mTLS enabled until we define a proper MeshTrafficPermission policy.
For now, the demo application won’t work.
You can verify this by clicking the increment button again and seeing the error message in the browser.
We can allow the traffic from the demo-app
to kv
by applying the following MeshTrafficPermission
:
kubectl apply -f https://raw.githubusercontent.com/kumahq/kuma-counter-demo/refs/heads/main/kustomize/overlays/001-with-mtls/mesh-traffic-permission.yaml
Which will create resource:
apiVersion: kuma.io/v1alpha1
kind: MeshTrafficPermission
metadata:
namespace: kuma-demo
name: kv
spec:
targetRef:
kind: Dataplane
labels:
app: kv
from:
- targetRef:
kind: MeshSubset
tags:
app: demo-app
k8s.kuma.io/namespace: kuma-demo
default:
action: Allow
You can click the increment button, the application should function once again.
However, the traffic to kv
from any other service than demo-app
is not allowed.