Este conteúdo não está disponível no idioma selecionado.
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 Copiar o linkLink copiado para a área de transferência!
- 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
Istioinstances:oc get istios
$ oc get istiosCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
You have installed the
istioctlbinary on your localhost.
6.2. About deploying multiple control planes Copiar o linkLink copiado para a área de transferência!
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 Copiar o linkLink copiado para a área de transferência!
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 Copiar o linkLink copiado para a área de transferência!
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 Copiar o linkLink copiado para a área de transferência!
You deploy the first control plane by creating its assigned namespace.
Procedure
Create the namespace for the first Istio control plane called
istio-system-1by running the following command:oc new-project istio-system-1
$ oc new-project istio-system-1Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the following label to the first namespace, which is used with the Istio
discoverySelectorsfield by running the following command:oc label namespace istio-system-1 istio-discovery=mesh-1
$ oc label namespace istio-system-1 istio-discovery=mesh-1Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a YAML file named
istio-1.yamlwith the namemesh-1and thediscoverySelectorasmesh-1:Example configuration
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the first
Istioresource by running the following command:oc apply -f istio-1.yaml
$ oc apply -f istio-1.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow To restrict workloads in
mesh-1from communicating freely with decrypted traffic between meshes, deploy aPeerAuthenticationresource to enforce mutual TLS (mTLS) traffic within themesh-1data plane. Apply thePeerAuthenticationresource in theistio-system-1namespace by using a configuration file, such aspeer-auth-1.yaml:oc apply -f peer-auth-1.yaml
$ oc apply -f peer-auth-1.yamlCopy 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 Copiar o linkLink copiado para a área de transferência!
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-2by running the following command:oc new-project istio-system-2
$ oc new-project istio-system-2Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the following label to the second namespace, which is used with the Istio
discoverySelectorsfield by running the following command:oc label namespace istio-system-2 istio-discovery=mesh-2
$ oc label namespace istio-system-2 istio-discovery=mesh-2Copy 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
Istioresource by running the following command:oc apply -f istio-2.yaml
$ oc apply -f istio-2.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy a policy for workloads in the
istio-system-2namespace to only accept mutual TLS trafficpeer-auth-2.yamlby running the following command:oc apply -f peer-auth-2.yaml
$ oc apply -f peer-auth-2.yamlCopy 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 Copiar o linkLink copiado para a área de transferência!
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-1by running the following command:oc get pods -n istio-system-1
$ oc get pods -n istio-system-1Copy 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 4m14sCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the workloads are assigned to the control plane in
istio-system-2by running the following command:oc get pods -n istio-system-2
$ oc get pods -n istio-system-2Copy 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 118sCopy to Clipboard Copied! Toggle word wrap Toggle overflow
6.5. Deploy application workloads in each mesh Copiar o linkLink copiado para a área de transferência!
To deploy application workloads, assign each workload to a separate namespace.
Procedure
Create an application namespace called
app-ns-1by running the following command:oc create namespace app-ns-1
$ oc create namespace app-ns-1Copy 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-1label by running the following command:oc label namespace app-ns-1 istio-discovery=mesh-1
$ oc label namespace app-ns-1 istio-discovery=mesh-1Copy 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-1label 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-1Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: You can verify the
mesh-1revision name by running the following command:oc get istiorevisions
$ oc get istiorevisionsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the
sleepandhttpbinapplications 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.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Wait for the
httpbinandsleeppods to run with sidecars injected by running the following command:oc get pods -n app-ns-1
$ oc get pods -n app-ns-1Copy 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 91mCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a second application namespace called
app-ns-2by running the following command:oc create namespace app-ns-2
$ oc create namespace app-ns-2Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a third application namespace called
app-ns-3by running the following command:oc create namespace app-ns-3
$ oc create namespace app-ns-3Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the label
istio-discovery=mesh-2to both namespaces and the revision labelmesh-2to 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-2Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the
sleepandhttpbinapplications to theapp-ns-2namespace 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.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the
sleepandhttpbinapplications to theapp-ns-3namespace 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.yamlCopy 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=AvailableCopy 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 pscommand after deploying the applications:Verify that the workloads are assigned to the control plane in
istio-system-1by running the following command:istioctl ps -i istio-system-1
$ istioctl ps -i istio-system-1Copy 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.0Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the workloads are assigned to the control plane in
istio-system-2by running the following command:istioctl ps -i istio-system-2
$ istioctl ps -i istio-system-2Copy 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.0Copy 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
sleeppod inapp-ns-1to thehttpbinservice inapp-ns-2to 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:8000Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
PeerAuthenticationresources created earlier enforce mutual TLS (mTLS) traffic inSTRICTmode within each mesh. Each mesh uses its own root certificate, managed by theistio-ca-root-certconfig 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: envoyCopy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm that the communication works by sending a request from the
sleeppod to thehttpbinservice that are present in theapp-ns-2namespace 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:8000Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow