Chapter 6. Deploying multiple service meshes on a single cluster
You can use the Red Hat OpenShift Service Mesh to operate multiple service meshes in a single cluster, with each mesh managed by a separate control plane. Using discovery selectors and revisions prevents conflicts between control planes.
6.1. Prerequisites Copy linkLink copied to clipboard!
- You have installed the OpenShift Service Mesh operator.
You have created an Istio Container Network Interface (CNI) resource.
NoteYou can run the following command to check for existing
Istio
instances:oc get istios
$ oc get istios
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
You have installed the
istioctl
binary on your localhost.
6.2. About deploying multiple control planes Copy linkLink copied to clipboard!
To configure a cluster to host two control planes, set up separate Istio resources with unique names in independent Istio system namespaces. Assign a unique revision name to each Istio resource to identify the control planes, workloads, or namespaces it manages. Apply these revision names using injection or istio.io/rev
labels to specify which control plane injects the sidecar proxy into application pods.
Each Istio
resource must also configure discovery selectors to specify which namespaces the Istio control plane observes. Only namespaces with labels that match the configured discovery selectors can join the mesh. Additionally, discovery selectors determine which control plane creates the istio-ca-root-cert
config map in each namespace, which is used to encrypt traffic between services with mutual TLS within each mesh.
When adding an additional Istio control plane to a cluster with an existing control plane, ensure that the existing Istio
instance has discovery selectors configured to avoid overlapping with the new control plane.
Only one IstioCNI
resource is shared by all control planes in a cluster, and you must update this resource independent of other cluster resources.
6.3. Using multiple control planes on a single cluster Copy linkLink copied to clipboard!
You can use discovery selectors to limit the visibility of an Istio control plane to specific namespaces in a cluster. By combining discovery selectors with control plane revisions, you can deploy multiple control planes in a single cluster, ensuring that each control plane manages only its assigned namespaces. This approach avoids conflicts between control planes and enables soft multi-tenancy for service meshes.
6.4. Deploying multiple control planes Copy linkLink copied to clipboard!
You can have extended support for more than two control planes. The maximum number of service meshes in a single cluster depends on the available cluster resources.
6.4.1. Deploying the first control plane Copy linkLink copied to clipboard!
You deploy the first control plane by creating its assigned namespace.
Procedure
Create the namespace for the first Istio control plane called
istio-system-1
by running the following command:oc new-project istio-system-1
$ oc new-project istio-system-1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the following label to the first namespace, which is used with the Istio
discoverySelectors
field by running the following command:oc label namespace istio-system-1 istio-discovery=mesh-1
$ oc label namespace istio-system-1 istio-discovery=mesh-1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a YAML file named
istio-1.yaml
with the namemesh-1
and thediscoverySelector
asmesh-1
:Example configuration
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the first
Istio
resource by running the following command:oc apply -f istio-1.yaml
$ oc apply -f istio-1.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To restrict workloads in
mesh-1
from communicating freely with decrypted traffic between meshes, deploy aPeerAuthentication
resource to enforce mutual TLS (mTLS) traffic within themesh-1
data plane. Apply thePeerAuthentication
resource in theistio-system-1
namespace by using a configuration file, such aspeer-auth-1.yaml
:oc apply -f peer-auth-1.yaml
$ oc apply -f peer-auth-1.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example configuration
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.4.2. Deploying the second control plane Copy linkLink copied to clipboard!
After deploying the first control plane, you can deploy the second control plane by creating its assigned namespace.
Procedure
Create a namespace for the second Istio control plane called
istio-system-2
by running the following command:oc new-project istio-system-2
$ oc new-project istio-system-2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the following label to the second namespace, which is used with the Istio
discoverySelectors
field by running the following command:oc label namespace istio-system-2 istio-discovery=mesh-2
$ oc label namespace istio-system-2 istio-discovery=mesh-2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a YAML file named
istio-2.yaml
:Example configuration
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the second
Istio
resource by running the following command:oc apply -f istio-2.yaml
$ oc apply -f istio-2.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy a policy for workloads in the
istio-system-2
namespace to only accept mutual TLS trafficpeer-auth-2.yaml
by running the following command:oc apply -f peer-auth-2.yaml
$ oc apply -f peer-auth-2.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example configuration
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.4.3. Verifying multiple control planes Copy linkLink copied to clipboard!
Verify that both of the Istio control planes are deployed and running properly. You can validate that the istiod
pod is successfully running in each Istio system namespace.
Verify that the workloads are assigned to the control plane in
istio-system-1
by running the following command:oc get pods -n istio-system-1
$ oc get pods -n istio-system-1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE istiod-mesh-1-b69646b6f-kxrwk 1/1 Running 0 4m14s
NAME READY STATUS RESTARTS AGE istiod-mesh-1-b69646b6f-kxrwk 1/1 Running 0 4m14s
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the workloads are assigned to the control plane in
istio-system-2
by running the following command:oc get pods -n istio-system-2
$ oc get pods -n istio-system-2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE istiod-mesh-2-8666fdfc6-mqp45 1/1 Running 0 118s
NAME READY STATUS RESTARTS AGE istiod-mesh-2-8666fdfc6-mqp45 1/1 Running 0 118s
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.5. Deploy application workloads in each mesh Copy linkLink copied to clipboard!
To deploy application workloads, assign each workload to a separate namespace.
Procedure
Create an application namespace called
app-ns-1
by running the following command:oc create namespace app-ns-1
$ oc create namespace app-ns-1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To ensure that the namespace is discovered by the first control plane, add the
istio-discovery=mesh-1
label by running the following command:oc label namespace app-ns-1 istio-discovery=mesh-1
$ oc label namespace app-ns-1 istio-discovery=mesh-1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To enable sidecar injection into all the pods by default while ensuring that pods in this namespace are mapped to the first control plane, add the
istio.io/rev=mesh-1
label to the namespace by running the following command:oc label namespace app-ns-1 istio.io/rev=mesh-1
$ oc label namespace app-ns-1 istio.io/rev=mesh-1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: You can verify the
mesh-1
revision name by running the following command:oc get istiorevisions
$ oc get istiorevisions
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the
sleep
andhttpbin
applications by running the following command:oc apply -n app-ns-1 \ -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.24/samples/sleep/sleep.yaml \ -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.24/samples/httpbin/httpbin.yaml
$ oc apply -n app-ns-1 \ -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.24/samples/sleep/sleep.yaml \ -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.24/samples/httpbin/httpbin.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Wait for the
httpbin
andsleep
pods to run with sidecars injected by running the following command:oc get pods -n app-ns-1
$ oc get pods -n app-ns-1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE httpbin-7f56dc944b-kpw2x 2/2 Running 0 2m26s sleep-5577c64d7c-b5wd2 2/2 Running 0 91m
NAME READY STATUS RESTARTS AGE httpbin-7f56dc944b-kpw2x 2/2 Running 0 2m26s sleep-5577c64d7c-b5wd2 2/2 Running 0 91m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a second application namespace called
app-ns-2
by running the following command:oc create namespace app-ns-2
$ oc create namespace app-ns-2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a third application namespace called
app-ns-3
by running the following command:oc create namespace app-ns-3
$ oc create namespace app-ns-3
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the label
istio-discovery=mesh-2
to both namespaces and the revision labelmesh-2
to match the discovery selector of the second control plane by running the following command:oc label namespace app-ns-2 app-ns-3 istio-discovery=mesh-2 istio.io/rev=mesh-2
$ oc label namespace app-ns-2 app-ns-3 istio-discovery=mesh-2 istio.io/rev=mesh-2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the
sleep
andhttpbin
applications to theapp-ns-2
namespace by running the following command:oc apply -n app-ns-2 \ -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.24/samples/sleep/sleep.yaml \ -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.24/samples/httpbin/httpbin.yaml
$ oc apply -n app-ns-2 \ -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.24/samples/sleep/sleep.yaml \ -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.24/samples/httpbin/httpbin.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the
sleep
andhttpbin
applications to theapp-ns-3
namespace by running the following command:oc apply -n app-ns-3 \ -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.24/samples/sleep/sleep.yaml \ -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.24/samples/httpbin/httpbin.yaml
$ oc apply -n app-ns-3 \ -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.24/samples/sleep/sleep.yaml \ -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.24/samples/httpbin/httpbin.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Use the following command to wait for a deployment to be available:
oc wait deployments -n app-ns-2 --all --for condition=Available
$ oc wait deployments -n app-ns-2 --all --for condition=Available
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that each application workload is managed by its assigned control plane by using the
istioctl ps
command after deploying the applications:Verify that the workloads are assigned to the control plane in
istio-system-1
by running the following command:istioctl ps -i istio-system-1
$ istioctl ps -i istio-system-1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME CLUSTER CDS LDS EDS RDS ECDS ISTIOD VERSION httpbin-7f56dc944b-vwfm5.app-ns-1 Kubernetes SYNCED (11m) SYNCED (11m) SYNCED (11m) SYNCED (11m) IGNORED istiod-mesh-1-b69646b6f-kxrwk 1.23.0 sleep-5577c64d7c-d675f.app-ns-1 Kubernetes SYNCED (11m) SYNCED (11m) SYNCED (11m) SYNCED (11m) IGNORED istiod-mesh-1-b69646b6f-kxrwk 1.23.0
NAME CLUSTER CDS LDS EDS RDS ECDS ISTIOD VERSION httpbin-7f56dc944b-vwfm5.app-ns-1 Kubernetes SYNCED (11m) SYNCED (11m) SYNCED (11m) SYNCED (11m) IGNORED istiod-mesh-1-b69646b6f-kxrwk 1.23.0 sleep-5577c64d7c-d675f.app-ns-1 Kubernetes SYNCED (11m) SYNCED (11m) SYNCED (11m) SYNCED (11m) IGNORED istiod-mesh-1-b69646b6f-kxrwk 1.23.0
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the workloads are assigned to the control plane in
istio-system-2
by running the following command:istioctl ps -i istio-system-2
$ istioctl ps -i istio-system-2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME CLUSTER CDS LDS EDS RDS ECDS ISTIOD VERSION httpbin-7f56dc944b-54gjs.app-ns-3 Kubernetes SYNCED (3m59s) SYNCED (3m59s) SYNCED (3m59s) SYNCED (3m59s) IGNORED istiod-mesh-2-8666fdfc6-mqp45 1.23.0 httpbin-7f56dc944b-gnh72.app-ns-2 Kubernetes SYNCED (4m1s) SYNCED (4m1s) SYNCED (3m59s) SYNCED (4m1s) IGNORED istiod-mesh-2-8666fdfc6-mqp45 1.23.0 sleep-5577c64d7c-k9mxz.app-ns-2 Kubernetes SYNCED (4m1s) SYNCED (4m1s) SYNCED (3m59s) SYNCED (4m1s) IGNORED istiod-mesh-2-8666fdfc6-mqp45 1.23.0 sleep-5577c64d7c-m9hvm.app-ns-3 Kubernetes SYNCED (4m1s) SYNCED (4m1s) SYNCED (3m59s) SYNCED (4m1s) IGNORED istiod-mesh-2-8666fdfc6-mqp45 1.23.0
NAME CLUSTER CDS LDS EDS RDS ECDS ISTIOD VERSION httpbin-7f56dc944b-54gjs.app-ns-3 Kubernetes SYNCED (3m59s) SYNCED (3m59s) SYNCED (3m59s) SYNCED (3m59s) IGNORED istiod-mesh-2-8666fdfc6-mqp45 1.23.0 httpbin-7f56dc944b-gnh72.app-ns-2 Kubernetes SYNCED (4m1s) SYNCED (4m1s) SYNCED (3m59s) SYNCED (4m1s) IGNORED istiod-mesh-2-8666fdfc6-mqp45 1.23.0 sleep-5577c64d7c-k9mxz.app-ns-2 Kubernetes SYNCED (4m1s) SYNCED (4m1s) SYNCED (3m59s) SYNCED (4m1s) IGNORED istiod-mesh-2-8666fdfc6-mqp45 1.23.0 sleep-5577c64d7c-m9hvm.app-ns-3 Kubernetes SYNCED (4m1s) SYNCED (4m1s) SYNCED (3m59s) SYNCED (4m1s) IGNORED istiod-mesh-2-8666fdfc6-mqp45 1.23.0
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verify that the application connectivity is restricted to workloads within their respective mesh:
Send a request from the
sleep
pod inapp-ns-1
to thehttpbin
service inapp-ns-2
to check that the communication fails by running the following command:oc -n app-ns-1 exec deploy/sleep -c sleep -- curl -sIL http://httpbin.app-ns-2.svc.cluster.local:8000
$ oc -n app-ns-1 exec deploy/sleep -c sleep -- curl -sIL http://httpbin.app-ns-2.svc.cluster.local:8000
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
PeerAuthentication
resources created earlier enforce mutual TLS (mTLS) traffic inSTRICT
mode within each mesh. Each mesh uses its own root certificate, managed by theistio-ca-root-cert
config map, which prevents communication between meshes. The output indicates a communication failure, similar to the following example:Example output
HTTP/1.1 503 Service Unavailable content-length: 95 content-type: text/plain date: Wed, 16 Oct 2024 12:05:37 GMT server: envoy
HTTP/1.1 503 Service Unavailable content-length: 95 content-type: text/plain date: Wed, 16 Oct 2024 12:05:37 GMT server: envoy
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm that the communication works by sending a request from the
sleep
pod to thehttpbin
service that are present in theapp-ns-2
namespace which is managed bymesh-2
. Run the following command:oc -n app-ns-2 exec deploy/sleep -c sleep -- curl -sIL http://httpbin.app-ns-3.svc.cluster.local:8000
$ oc -n app-ns-2 exec deploy/sleep -c sleep -- curl -sIL http://httpbin.app-ns-3.svc.cluster.local:8000
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow