apiVersion: maistra.io/v2
kind: ServiceMeshControlPlane
spec:
version: v2.2
security:
dataPlane:
mtls: true
If your service mesh application is constructed with a complex array of microservices, you can use Red Hat OpenShift Service Mesh to customize the security of the communication between those services. The infrastructure of OpenShift Container Platform along with the traffic management features of Service Mesh help you manage the complexity of your applications and secure microservices.
If you have a project, add your project to the ServiceMeshMemberRoll
resource.
If you don’t have a project, install the Bookinfo sample application and add it to the ServiceMeshMemberRoll
resource. The sample application helps illustrate security concepts.
Mutual Transport Layer Security (mTLS) is a protocol that enables two parties to authenticate each other. It is the default mode of authentication in some protocols (IKE, SSH) and optional in others (TLS). You can use mTLS without changes to the application or service code. The TLS is handled entirely by the service mesh infrastructure and between the two sidecar proxies.
By default, mTLS in Red Hat OpenShift Service Mesh is enabled and set to permissive mode, where the sidecars in Service Mesh accept both plain-text traffic and connections that are encrypted using mTLS. If a service in your mesh is communicating with a service outside the mesh, strict mTLS could break communication between those services. Use permissive mode while you migrate your workloads to Service Mesh. Then, you can enable strict mTLS across your mesh, namespace, or application.
Enabling mTLS across your mesh at the Service Mesh control plane level secures all the traffic in your service mesh without rewriting your applications and workloads. You can secure namespaces in your mesh at the data plane level in the ServiceMeshControlPlane
resource. To customize traffic encryption connections, configure namespaces at the application level with PeerAuthentication
and DestinationRule
resources.
If your workloads do not communicate with outside services, you can quickly enable mTLS across your mesh without communication interruptions. You can enable it by setting spec.security.dataPlane.mtls
to true
in the ServiceMeshControlPlane
resource. The Operator creates the required resources.
apiVersion: maistra.io/v2
kind: ServiceMeshControlPlane
spec:
version: v2.2
security:
dataPlane:
mtls: true
You can also enable mTLS by using the OpenShift Container Platform web console.
Log in to the web console.
Click the Project menu and select the project where you installed the Service Mesh control plane, for example istio-system.
Click Operators → Installed Operators.
Click Service Mesh Control Plane under Provided APIs.
Click the name of your ServiceMeshControlPlane
resource, for example, basic
.
On the Details page, click the toggle in the Security section for Data Plane Security.
You can also configure mTLS for individual services by creating a policy.
Create a YAML file using the following example.
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: default
namespace: <namespace>
spec:
mtls:
mode: STRICT
Replace <namespace>
with the namespace where the service is located.
Run the following command to create the resource in the namespace where the service is located. It must match the namespace
field in the Policy resource you just created.
$ oc create -n <namespace> -f <policy.yaml>
If you are not using automatic mTLS and you are setting |
Create a destination rule to configure Service Mesh to use mTLS when sending requests to other services in the mesh.
Create a YAML file using the following example.
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: default
namespace: <namespace>
spec:
host: "*.<namespace>.svc.cluster.local"
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
Replace <namespace>
with the namespace where the service is located.
Run the following command to create the resource in the namespace where the service is located. It must match the namespace
field in the DestinationRule
resource you just created.
$ oc create -n <namespace> -f <destination-rule.yaml>
If your environment has specific requirements for encrypted traffic in your service mesh, you can control the cryptographic functions that are allowed by setting the spec.security.controlPlane.tls.minProtocolVersion
or spec.security.controlPlane.tls.maxProtocolVersion
in your ServiceMeshControlPlane
resource. Those values, configured in your Service Mesh control plane resource, define the minimum and maximum TLS version used by mesh components when communicating securely over TLS.
The default is TLS_AUTO
and does not specify a version of TLS.
Value | Description |
---|---|
|
default |
|
TLS version 1.0 |
|
TLS version 1.1 |
|
TLS version 1.2 |
|
TLS version 1.3 |
Log in to the web console.
Click the Project menu and select the project where you installed the Service Mesh control plane, for example istio-system.
Click Operators → Installed Operators.
Click Service Mesh Control Plane under Provided APIs.
Click the name of your ServiceMeshControlPlane
resource, for example, basic
.
Click the YAML tab.
Insert the following code snippet in the YAML editor. Replace the value in the minProtocolVersion
with the TLS version value. In this example, the minimum TLS version is set to TLSv1_2
.
kind: ServiceMeshControlPlane
spec:
security:
controlPlane:
tls:
minProtocolVersion: TLSv1_2
Click Save.
Click Refresh to verify that the changes updated correctly.
The Kiali console offers several ways to validate whether or not your applications, services, and workloads have mTLS encryption enabled.
At the right side of the masthead, Kiali shows a lock icon when the mesh has strictly enabled mTLS for the whole service mesh. It means that all communications in the mesh use mTLS.
Kiali displays a hollow lock icon when either the mesh is configured in PERMISSIVE
mode or there is a error in the mesh-wide mTLS configuration.