1.10.5.2. Adding a project to the mesh using label selectors with the CLI
You can use label selectors to add a project to the Service Mesh with the CLI.
Prerequisites
- You have installed the Red Hat OpenShift Service Mesh Operator.
-
The deployment has an existing
ServiceMeshMemberRollresource. - You are logged in to OpenShift Container Platform as`cluster-admin`.
Procedure
- Log in to the OpenShift Container Platform CLI.
Edit the
ServiceMeshMemberRollresource.$ oc edit smmr default -n istio-systemYou can deploy the Service Mesh control plane to any project provided that it is separate from the project that contains your services.
Modify the YAML file to include namespace label selectors in the
spec.memberSelectorsfield of theServiceMeshMemberRollresource.참고Instead of using the
matchLabelsfield, you can also use thematchExpressionsfield in the selector.apiVersion: maistra.io/v1 kind: ServiceMeshMemberRoll metadata: name: default namespace: istio-system spec: memberSelectors:1 - matchLabels:2 mykey: myvalue3 - matchLabels:4 myotherkey: myothervalue5 - 1
- Contains the label selectors used to identify which project namespaces are included in the service mesh. If a project namespace has either label specified by the selectors, then the project namespace is included in the service mesh. The project namespace does not need both labels to be included.
- 2 3
- Specifies all namespaces with the
mykey=myvaluelabel. When the selector identifies a match, the project namespace is added to the service mesh. - 4 5
- Specifies all namespaces with the
myotherkey=myothervaluelabel. When the selector identifies a match, the project namespace is added to the service mesh.