Este contenido no está disponible en el idioma seleccionado.
Chapter 6. Deploying multiple service meshes on a single cluster
You can use the Red Hat OpenShift Service Mesh to operate many 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. About deploying multiple control planes Copiar enlaceEnlace copiado en el portapapeles!
You can configure a cluster to host multiple control planes by deploying unique Istio resources in separate namespaces and using revision labels to manage sidecar injection for specific workloads.
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 encrypts 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.
All control planes in a cluster share a single IstioCNI resource, and you must update this resource independent of other cluster resources.
6.2. Using multiple control planes on a single cluster Copiar enlaceEnlace copiado en el portapapeles!
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.2.1. Deploying the first control plane Copiar enlaceEnlace copiado en el portapapeles!
You deploy the first control plane by creating its assigned namespace.
Prerequisites
- 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-
You have installed the
istioctlbinary on your localhost.
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.
Procedure
Create the namespace for the first Istio control plane called
istio-system-1by running the following command:$ oc new-project istio-system-1Label the first namespace, which the Istio
discoverySelectorsfield uses by running the following command:$ oc label namespace istio-system-1 istio-discovery=mesh-1Create a YAML file named
istio-1.yamlwith the namemesh-1and thediscoverySelectorasmesh-1similar to the following example:kind: Istio apiVersion: sailoperator.io/v1 metadata: name: mesh-1 spec: namespace: istio-system-1 values: meshConfig: discoverySelectors: - matchLabels: istio-discovery: mesh-1 # ...Create the first
Istioresource by running the following command:$ oc apply -f istio-1.yamlTo 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, by running the following command:$ oc apply -f peer-auth-1.yamlYou can see the following example configuration for reference:
apiVersion: security.istio.io/v1 kind: PeerAuthentication metadata: name: "mesh-1-peerauth" namespace: "istio-system-1" spec: mtls: mode: STRICT
6.2.2. Deploying the second control plane Copiar enlaceEnlace copiado en el portapapeles!
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-2Label the second namespace, which the Istio
discoverySelectorsfield uses by running the following command:$ oc label namespace istio-system-2 istio-discovery=mesh-2Create a YAML file named
istio-2.yamlsimilar to the following example:kind: Istio apiVersion: sailoperator.io/v1 metadata: name: mesh-2 spec: namespace: istio-system-2 values: meshConfig: discoverySelectors: - matchLabels: istio-discovery: mesh-2 # ...Create the second
Istioresource by running the following command:$ oc apply -f istio-2.yamlDeploy 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.yamlYou can see the following example configuration for reference:
apiVersion: security.istio.io/v1 kind: PeerAuthentication metadata: name: "mesh-2-peerauth" namespace: "istio-system-2" spec: mtls: mode: STRICT
6.2.3. Verifying multiple control planes Copiar enlaceEnlace copiado en el portapapeles!
Verify that both Istio control planes deploy and run as expected. You can validate that the istiod pod is successfully running in each Istio system namespace.
Procedure
Verify that the control plane in
istio-system-1manages the workloads by running the following command:$ oc get pods -n istio-system-1You should see output similar to the following example:
NAME READY STATUS RESTARTS AGE istiod-mesh-1-b69646b6f-kxrwk 1/1 Running 0 4m14sVerify that the control plane in
istio-system-2manages the workloads by running the following command:$ oc get pods -n istio-system-2You should see output similar to the following example:
NAME READY STATUS RESTARTS AGE istiod-mesh-2-8666fdfc6-mqp45 1/1 Running 0 118s
6.3. Deploy application workloads in each mesh Copiar enlaceEnlace copiado en el portapapeles!
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-1To ensure the first control plane discovers the namespace, add the
istio-discovery=mesh-1label by running the following command:$ oc label namespace app-ns-1 istio-discovery=mesh-1To enable sidecar injection into all the pods by default, while mapping the pods in this namespace 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-1Optional: You can verify the
mesh-1revision name by running the following command:$ oc get istiorevisionsDeploy 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.yamlWait for the
httpbinandsleeppods to run with sidecars injected by running the following command:$ oc get pods -n app-ns-1You should see output similar to the following example:
NAME READY STATUS RESTARTS AGE httpbin-7f56dc944b-kpw2x 2/2 Running 0 2m26s sleep-5577c64d7c-b5wd2 2/2 Running 0 91mCreate a second application namespace called
app-ns-2by running the following command:$ oc create namespace app-ns-2Create a third application namespace called
app-ns-3by running the following command:$ oc create namespace app-ns-3Add 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-2Deploy 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.yamlDeploy 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.yamlOptional: Use the following command to wait for a deployment to be available:
$ oc wait deployments -n app-ns-2 --all --for condition=Available
Verification
After deploying the applications, use the
istioctl pscommand to verify that the correct control plane manages each workload:Verify that the
istio-system-1control plane manages the workloads by running the following command:$ istioctl ps -i istio-system-1You should see output similar to the following example:
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.0Verify that the
istio-system-2control plane manages the workloads by running the following command:$ istioctl ps -i istio-system-2You should see output similar to the following example:
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
Verify that the mesh restricts application connectivity to local workloads:
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:8000The
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:You should see output similar to the following example:
HTTP/1.1 503 Service Unavailable content-length: 95 content-type: text/plain date: Wed, 16 Oct 2024 12:05:37 GMT server: envoyConfirm that the communication works by sending a request from the
sleeppod to thehttpbinservice that are present in theapp-ns-2namespace, whichmesh-2manages by running the following command:$ oc -n app-ns-2 exec deploy/sleep -c sleep -- curl -sIL http://httpbin.app-ns-3.svc.cluster.local:8000You should see output similar to the following example:
HTTP/1.1 200 OK access-control-allow-credentials: true access-control-allow-origin: * content-security-policy: default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' camo.githubusercontent.com content-type: text/html; charset=utf-8 date: Wed, 16 Oct 2024 12:06:30 GMT x-envoy-upstream-service-time: 8 server: envoy transfer-encoding: chunked