This guide demonstrates a client and server application within the service mesh communicating using OSM’s permissive traffic policy mode, which configures application connectivity using service discovery without the need for explicit SMI traffic access policies.
Prerequisites
- Kubernetes cluster running Kubernetes v1.20.0 or greater.
- Have OSM installed.
- Have
kubectlavailable to interact with the API server. - Have
osmCLI available for managing the service mesh.
Demo
The following demo shows an HTTP curl client making HTTP requests to the httpbin service using permissive traffic policy mode.
Enable permissive mode if not enabled.
export osm_namespace=osm-system # Replace osm-system with the namespace where OSM is installedkubectl patch meshconfig osm-mesh-config -n "$osm_namespace" -p '{"spec":{"traffic":{"enablePermissiveTrafficPolicyMode":true}}}' --type=merge
Deploy the
httpbinservice into thehttpbinnamespace after enrolling its namespace to the mesh. Thehttpbinservice runs on port14001.# Create the httpbin namespacekubectl create namespace httpbin# Add the namespace to the meshosm namespace add httpbin# Deploy httpbin service in the httpbin namespacekubectl apply -f https://raw.githubusercontent.com/openservicemesh/osm-docs/release-v1.1/manifests/samples/httpbin/httpbin.yaml -n httpbin
Confirm the
httpbinservice and pods are up and running.$ kubectl get svc -n httpbinNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEhttpbin ClusterIP 10.96.198.23 <none> 14001/TCP 20s
$ kubectl get pods -n httpbinNAME READY STATUS RESTARTS AGEhttpbin-5b8b94b9-lt2vs 2/2 Running 0 20s
Deploy the
curlclient into thecurlnamespace after enrolling its namespace to the mesh.# Create the curl namespacekubectl create namespace curl# Add the namespace to the meshosm namespace add curl# Deploy curl client in the curl namespacekubectl apply -f https://raw.githubusercontent.com/openservicemesh/osm-docs/release-v1.1/manifests/samples/curl/curl.yaml -n curl
Confirm the
curlclient pod is up and running.$ kubectl get pods -n curlNAME READY STATUS RESTARTS AGEcurl-54ccc6954c-9rlvp 2/2 Running 0 20s
Confirm the
curlclient is able to access thehttpbinservice on port14001.$ kubectl exec -n curl -ti "$(kubectl get pod -n curl -l app=curl -o jsonpath='{.items[0].metadata.name}')" -c curl -- curl -I http://httpbin.httpbin:14001HTTP/1.1 200 OKserver: envoydate: Mon, 15 Mar 2021 22:45:23 GMTcontent-type: text/html; charset=utf-8content-length: 9593access-control-allow-origin: *access-control-allow-credentials: truex-envoy-upstream-service-time: 2
A
200 OKresponse indicates the HTTP request from thecurlclient to thehttpbinservice was successful.Confirm the HTTP requests fail when permissive traffic policy mode is disabled.
kubectl patch meshconfig osm-mesh-config -n "$osm_namespace" -p '{"spec":{"traffic":{"enablePermissiveTrafficPolicyMode":false}}}' --type=merge
$ kubectl exec -n curl -ti "$(kubectl get pod -n curl -l app=curl -o jsonpath='{.items[0].metadata.name}')" -c curl -- curl -I http://httpbin.httpbin:14001curl: (7) Failed to connect to httpbin.httpbin port 14001: Connection refusedcommand terminated with exit code 7
