Red Hat OpenShift service Mesh installs a serviceMeshControlPlane
that is configured for multitenancy by default. Red Hat OpenShift service Mesh uses a multitenant Operator to manage the service Mesh control plane lifecycle. Within a mesh, namespaces are used for tenancy.
Red Hat OpenShift service Mesh uses serviceMeshControlPlane
resources to manage mesh installations, whose scope is limited by default to namespace that contains the resource. You use serviceMeshMemberRoll
and serviceMeshMember
resources to include additional namespaces into the mesh. A namespace can only be included in a single mesh, and multiple meshes can be installed in a single OpenShift cluster.
Typical service mesh deployments use a single service Mesh control plane to configure communication between services in the mesh. Red Hat OpenShift service Mesh supports “soft multitenancy”, where there is one control plane and one mesh per tenant, and there can be multiple independent control planes within the cluster. Multitenant deployments specify the projects that can access the service Mesh and isolate the service Mesh from other control plane instances.
The cluster administrator gets control and visibility across all the Istio control planes, while the tenant administrator only gets control over their specific service Mesh, Kiali, and Jaeger instances.
You can grant a team permission to deploy its workloads only to a given namespace or set of namespaces. If granted the mesh-user
role by the service mesh administrator, users can create a serviceMeshMember
resource to add namespaces to the serviceMeshMemberRoll
.
About migrating to a cluster-wide mesh
In a cluster-wide mesh, one serviceMeshControlPlane
(SMCP) watches all of the namespaces for an entire cluster. You can migrate an existing cluster from a multitenant mesh to a cluster-wide mesh using Red Hat OpenShift service Mesh version 2.5 or later.
|
If a cluster must have more than one SMCP, then you cannot migrate to a cluster-wide mesh.
|
By default, a cluster-wide mesh discovers all of the namespaces that comprise a cluster. However, you can configure the mesh to access a limited set of namespaces. Namespaces do not receive sidecar injection by default. You must specify which namespaces receive sidecar injection.
Similarly, you must specify which pods receive sidecar injection. Pods that exist in a namespace that receives sidecar injection do not inherit sidecar injection. Applying sidecar injection to namespaces and to pods are separate operations.
If you change the Istio version when migrating to a cluster-wide mesh, then you must restart the applications. If you use the same Istio version, the application proxies will connect to the new SMCP for the cluster-wide mesh, and work the same way they did for a multitenant mesh.
Including and excluding namespaces from a cluster-wide mesh by using the web console
Using the OpenShift Dedicated web console, you can add discovery selectors to the serviceMeshControlPlane
resource in a cluster-wide mesh. Discovery selectors define the namespaces that the control plane can discover. The control plane ignores any namespace that does not match one of the discovery selectors, which excludes the namespace from the mesh.
|
If you install ingress or egress gateways in the control plane namespace, you must include the control plane namespace in the discovery selectors.
|
Prerequisites
-
You have installed the Red Hat OpenShift service Mesh Operator.
-
You have deployed a serviceMeshControlPlane
resource.
-
You are logged in as a user with the cluster-admin
role. If you use Red Hat OpenShift Dedicated, you are logged in as a user with the dedicated-admin
role.
Procedure
-
Log in to the OpenShift Dedicated web console.
-
Navigate to Operators → Installed Operators.
-
Click the Red Hat OpenShift service Mesh Operator.
-
Click Istio service Mesh Control Plane.
-
Click the name of the control plane.
-
Click YAML.
-
Modify the YAML file so that the spec.meshConfig
field of the serviceMeshControlPlane
resource includes the discovery selector.
|
When configuring namespaces that the Istiod service can discover, exclude namespaces that might contain sensitive services that should not be exposed to the rest of the mesh.
|
In the following example, the Istiod
service discovers any namespace that is labeled istio-discovery: enabled
or any namespace that has the name bookinfo
, httpbin
or istio-system
:
apiVersion: maistra.io/v2
kind: serviceMeshControlPlane
metadata:
name: basic
spec:
mode: ClusterWide
meshConfig:
discoverySelectors:
- matchLabels:
istio-discovery: enabled (1)
- matchExpressions:
- key: kubernetes.io/metadata.name (2)
operator: In
values:
- bookinfo
- httpbin
- istio-system
1 |
Ensures that the mesh discovers namespaces that contain the label istio-discovery: enabled . |
2 |
Ensures that the mesh discovers namespaces bookinfo , httpbin and istio-system . |
If a namespace matches any of the discovery selectors, then the mesh discovers the namespace. The mesh excludes namespaces that do not match any of the discovery selectors.
-
Save the file.
Including and excluding namespaces from a cluster-wide mesh by using the CLI
Using the OpenShift Dedicated CLI, you can add discovery selectors to the serviceMeshControlPlane
resource in a cluster-wide mesh. Discovery selectors define the namespaces that the control plane can discover. The control plane ignores any namespace that does not match one of the discovery selectors, which excludes the namespace from the mesh.
|
If you install ingress or egress gateways in the control plane namespace, you must include the control plane namespace in the discovery selectors.
|
Prerequisites
-
You have installed the Red Hat OpenShift service Mesh Operator.
-
You have deployed a serviceMeshControlPlane
resource.
-
You are logged in as a user with the cluster-admin
role. If you use Red Hat OpenShift Dedicated, you are logged in as a user with the dedicated-admin
role.
Procedure
-
Log in to the OpenShift Dedicated CLI.
-
Open the serviceMeshControlPlane
resource as a YAML file by running the following command:
$ oc -n istio-system edit smcp <name> (1)
1 |
<name> represents the name of the serviceMeshControlPlane resource. |
-
Modify the YAML file so that the spec.meshConfig
field of the serviceMeshControlPlane
resource includes the discovery selector.
|
When configuring namespaces that the Istiod service can discover, exclude namespaces that might contain sensitive services that should not be exposed to the rest of the mesh.
|
In the following example, the Istiod
service discovers any namespace that is labeled istio-discovery: enabled
or any namespace that has the name bookinfo
, httpbin
or istio-system
:
apiVersion: maistra.io/v2
kind: serviceMeshControlPlane
metadata:
name: basic
spec:
mode: ClusterWide
meshConfig:
discoverySelectors:
- matchLabels:
istio-discovery: enabled (1)
- matchExpressions:
- key: kubernetes.io/metadata.name (2)
operator: In
values:
- bookinfo
- httpbin
- istio-system
1 |
Ensures that the mesh discovers namespaces that contain the label istio-discovery: enabled . |
2 |
Ensures that the mesh discovers namespaces bookinfo , httpbin and istio-system . |
If a namespace matches any of the discovery selectors, then the mesh discovers the namespace. The mesh excludes namespaces that do not match any of the discovery selectors.
-
Save the file and exit the editor.
Defining which namespaces receive sidecar injection in a cluster-wide mesh by using the web console
By default, the Red Hat OpenShift service Mesh Operator uses member selectors to identify which namespaces receive sidecar injection. Namespaces that do not match the istio-injection=enabled
label as defined in the serviceMeshMemberRoll
resource do not receive sidecar injection.
|
Using discovery selectors to determine which namespaces the mesh can discover has no effect on sidecar injection. Discovering namespaces and configuring sidecar injection are separate operations.
|
Prerequisites
-
You have installed the Red Hat OpenShift service Mesh Operator.
-
You have deployed a serviceMeshControlPlanae
resource with the mode: ClusterWide
annotation.
-
You are logged in as a user with the cluster-admin
role. If you use Red Hat OpenShift Dedicated, you are logged in as a user with the dedicated-admin
role.
Procedure
-
Log in to the OpenShift Dedicated web console.
-
Navigate to Operators → Installed Operators.
-
Click the Red Hat OpenShift service Mesh Operator.
-
Click Istio service Mesh Member Roll.
-
Click the serviceMeshMemberRoll
resource.
-
Click YAML.
-
Modify the spec.memberSelectors
field in the serviceMeshMemberRoll
resource by adding a member selector that matches the inject
label. The following example uses istio-injection: enabled
:
apiVersion: maistra.io/v1
kind: serviceMeshMemberRoll
metadata:
name: default
spec:
memberSelectors:
- matchLabels:
istio-injection: enabled (1)
1 |
Ensures that the namespace receives sidecar injection. |
-
Save the file.
Defining which namespaces receive sidecar injection in a cluster-wide mesh by using the CLI
By default, the Red Hat OpenShift service Mesh Operator uses member selectors to identify which namespaces receive sidecar injection. Namespaces that do not match the istio-injection=enabled
label as defined in the serviceMeshMemberRoll
resource do not receive sidecar injection.
|
Using discovery selectors to determine which namespaces the mesh can discover has no effect on sidecar injection. Discovering namespaces and configuring sidecar injection are separate operations.
|
Prerequisites
-
You have installed the Red Hat OpenShift service Mesh Operator.
-
You have deployed a serviceMeshControlPlanae
resource with the mode: ClusterWide
annotation.
-
You are logged in as a user with the cluster-admin
role. If you use Red Hat OpenShift Dedicated, you are logged in as a user with the dedicated-admin
role.
Procedure
-
Log in to the OpenShift Dedicated CLI.
-
Edit the serviceMeshMemberRoll
resource.
$ oc edit smmr -n <controlplane-namespace>
-
Modify the spec.memberSelectors
field in the serviceMeshMemberRoll
resource by adding a member selector that matches the inject
label. The following example uses istio-injection: enabled
:
apiVersion: maistra.io/v1
kind: serviceMeshMemberRoll
metadata:
name: default
spec:
memberSelectors:
- matchLabels:
istio-injection: enabled (1)
1 |
Ensures that the namespace receives sidecar injection. |
-
Save the file and exit the editor.
Excluding individual pods from a cluster-wide mesh by using the web console
A pod receives sidecar injection if it has the sidecar.istio.io/inject: true
annotation applied, and the pod exists in a namespace that matches either the label selector or the members list defined in the serviceMeshMemberRoll
resource.
If a pod does not have the sidecar.istio.io/inject
annotation applied, it cannot receive sidecar injection.
Prerequisites
-
You have installed the Red Hat OpenShift service Mesh Operator.
-
You have deployed a serviceMeshControlPlane
resource with the mode: ClusterWide
annotation.
-
You are logged in as a user with the cluster-admin
role. If you use Red Hat OpenShift Dedicated, you are logged in as a user with the dedicated-admin
role.
Procedure
-
Log in to the OpenShift Dedicated web console.
-
Navigate to Workloads → Deployments.
-
Click the name of the deployment.
-
Click YAML.
-
Modify the YAML file to deploy one application that receives sidecar injection and one that does not, as shown in the following example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
annotations:
sidecar.istio.io/inject: 'true' (1)
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-without-sidecar
spec:
selector:
matchLabels:
app: nginx-without-sidecar
template:
metadata:
labels:
app: nginx-without-sidecar (2)
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
1 |
This pod has the sidecar.istio.io/inject annotation applied, so it receives sidecar injection. |
2 |
This pod does not have the annotation, so it does not receive sidecar injection. |
-
Save the file.
Excluding individual pods from a cluster-wide mesh by using the CLI
A pod receives sidecar injection if it has the sidecar.istio.io/inject: true
annotation applied, and the pod exists in a namespace that matches either the label selector or the members list defined in the serviceMeshMemberRoll
resource.
If a pod does not have the sidecar.istio.io/inject
annotation applied, it cannot receive sidecar injection.
Prerequisites
-
You have installed the Red Hat OpenShift service Mesh Operator.
-
You have deployed a serviceMeshControlPlane
resource with the mode: ClusterWide
annotation.
-
You are logged in as a user with the cluster-admin
role. If you use Red Hat OpenShift Dedicated, you are logged in as a user with the dedicated-admin
role.
Procedure
-
Log in to the OpenShift Dedicated CLI.
-
Edit the deployment by running the following command:
$ oc edit deployment -n <namespace> <deploymentName>
-
Modify the YAML file to deploy one application that receives sidecar injection and one that does not, as shown in the following example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
annotations:
sidecar.istio.io/inject: 'true' (1)
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-without-sidecar
spec:
selector:
matchLabels:
app: nginx-without-sidecar
template:
metadata:
labels:
app: nginx-without-sidecar (2)
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
1 |
This pod has the sidecar.istio.io/inject annotation applied, so it receives sidecar injection. |
2 |
This pod does not have the annotation, so it does not receive sidecar injection. |
-
Save the file.