Red Hat Service Mesh Deep Dive
Red Hat Service Mesh Deep Dive
OpenShift
Workshop OpenShift Service
Mesh
Vodafone Oman
Shah Zobair
Principal Consultant
March 02, 2022
V0000000
CONFIDENTIAL designator
Role Mail
2
V0000000
Agenda CONFIDENTIAL designator
3
V0000000
CONFIDENTIAL designator
Basic Concepts
4
V0000000
CONFIDENTIAL designator
In early days we used to have multi tiers applications typically 3-tiers applications:
● Frontend server.
● Business logic layer: a very large monolithic app.
● Backend: can be a database, a filesystem, or an external API.
5
V0000000
CONFIDENTIAL designator
6
V0000000
CONFIDENTIAL designator
● As more and more users start to come in, it would create a challenge.
● You could add more front end server behind a load balancer.
7
V0000000
CONFIDENTIAL designator
Frontend 1
Microservices Approach
Microservices are an architectural approach to building application that consists of distributed and loosely coupled services,
in a way that one team’s changes won’t break the entire app.
9
V0000000
CONFIDENTIAL designator
Users
Firewall
External External
10 API 1 API 2
V0000000
CONFIDENTIAL designator
What happened at scale when hundred or thousand microservice are running inside the container environment?
In case of troubleshooting, we have to trace individually requests that go the involved microservices.
11
V0000000
CONFIDENTIAL designator
Microservices Fallacies
12
V0000000
CONFIDENTIAL designator
Service
- Configuration
- Service Discovery
Tracing
Circuit Breaker
- Dynamic Routing
Routing
Svc Discovery
- Resilience
Config - Observability
Platform
13
V0000000
CONFIDENTIAL designator
When using a service mesh, the supporting services for distributed applications are provided via the
container platform and service mesh.
Service
Tracing
Circuit Breaker
Routing
Svc Discovery
Service
Config
Container Platform
Platform
(+ Service Mesh)
...2014 2018
14
V0000000
Microservice architecture with/without a service mesh CONFIDENTIAL designator
15
V0000000
CONFIDENTIAL designator
● Performance -> The application should perform within a some defined parameters (ex: response time).
● Security -> Access to the data must be secure and prevented from any unattended malicious attack.
● Graceful error handling -> If external service are not available, how to handle properly without stucking the application.
16
V0000000
CONFIDENTIAL designator
17
V0000000
CONFIDENTIAL designator
Istio
18
V0000000
CONFIDENTIAL designator
Istio Project
Istio makes it easy to create a network of deployed services with load balancing, service-to-service
authentication, monitoring, and more, without any changes in the service code.
19
V0000000
CONFIDENTIAL designator
Istio Architecture
Control Plane
20
V0000000
CONFIDENTIAL designator
istiod
21
V0000000
CONFIDENTIAL designator
22
V0000000
CONFIDENTIAL designator
OpenShift
Service Mesh
23
V0000000
CONFIDENTIAL designator
Based on the open source Istio project, Red Hat OpenShift Service Mesh provides a platform for
behavioral insight and operational control over your networked microservices in a service mesh.
ANY
INFRASTRUCTURE
Laptop Datacenter OpenStack Amazon Web Services Microsoft Azure Google Cloud
24
V0000000
CONFIDENTIAL designator
OpenShift Service Mesh
V0000000
Multi-Tenancy - Mesh and non mesh (1/2) CONFIDENTIAL designator
Namespace A
Non mesh managed Namespace C
namespace N...
Namespace z
Namespace x
26
Multi-Tenancy - Mesh and non mesh (2/2) CONFIDENTIAL designator
Service Mesh n - A mesh is composed of one control plane and one data plane. Several mesh
Control Plane n
Namespace
can coexist inside the cluster.
Namespace C namespace.
V0000000
27
CONFIDENTIAL designator
Multi-Tenancy - Implementation
28
V0000000
Multi-Tenancy - Network Policies (1/2)
CONFIDENTIAL designator
● OpenShift Service Mesh creates NetworkPolicy resources in control plane namespace and each namespaces member
of data plane.
● If you remove a namespace member from data plane, this NetworkPolicy resource is deleted from the project.
29
V0000000
Multi-Tenancy - Network Policies (2/2)
CONFIDENTIAL designator
When creating a new dataplane, each namespace belonging will have two Network Policies defined by default.
istio-mesh-basic: This policy will force all your pods to communicate only with pods included data plane namespace(s).
Data plane namespaces are identified with the namespace label maistra.io/member-of=<control plane namespace>
istio-expose-route: This policy allows Ingress Controller route traffic to be exposed for pod that will have explicit label
maistra.io/expose-route=”true”.
30
V0000000
CONFIDENTIAL designator
Jaeger
31
V0000000
Jaeger CONFIDENTIAL designator
Jaeger lets you perform tracing to monitor and troubleshoot transactions in complex distributed systems.
Kiali
33
V0000000
CONFIDENTIAL designator
Kiali (1/2)
Kiali provides observability for your service mesh. By using Kiali you can view configurations, monitor traffic, and view and
analyze traces in a single console.
34
V0000000
CONFIDENTIAL designator
Kiali (2/2)
Prometheus
36
V0000000
CONFIDENTIAL designator
Prometheus
Installation
38
V0000000
CONFIDENTIAL designator
Installation Prerequisites
To install the Red Hat OpenShift Service Mesh Operator, you must first install these Operators:
Based on the open source Elasticsearch project that enables you to configure and
Elasticsearch
manage an Elasticsearch cluster for tracing and logging with Jaeger.
Based on the open source Jaeger project, lets you perform tracing to monitor and
Jaeger
troubleshoot transactions in complex distributed systems.
Based on the open source Kiali project, provides observability for your service mesh.
Kiali By using Kiali you can view configurations, monitor traffic, and view and analyze traces
in a single console.
Red Hat OpenShift Service Mesh does not support Istio installation profiles.
Red Hat OpenShift Service Mesh does not support canary upgrades of the service mesh.
39
V0000000
Service Mesh Installation - Elasticsearch
CONFIDENTIAL designator
V0000000
CONFIDENTIAL designator
Hardware
requirements
44
V0000000
Control Plane resources
CONFIDENTIAL designator
Istiod 1 1.5 GB
Kiali 0.01 64 MB
45
V0000000
Data Plane resources
CONFIDENTIAL designator
46
V0000000
*The Envoy proxy adds 3.12 ms to the 90th percentile latency.
Sizing consideration (1/3)
CONFIDENTIAL designator
Istiod’s CPU and memory requirements scale with the number of configurations and possible system states.
47
V0000000
Sizing consideration (2/3)
CONFIDENTIAL designator
- Protocol.
- CPU cores.
48
V0000000
Sizing consideration (3/3)
CONFIDENTIAL designator
- Sampling rate.
- Number of requests.
49
V0000000
CONFIDENTIAL designator
Configuration
prerequisites
50
V0000000
Ingress Controller for Network policies
CONFIDENTIAL designator
Depending the infrastructure platform and Ingress Controller setting during cluster installation, you have to configure
the Ingress network traffic support for Network policies
If endpointPublishingStrategy is set to HostNetwork, then the Ingress Controller pod runs on the host network. The
traffic is assigned the netid:0 Virtual Network ID (VNID).
Because Ingress Controller namespace has a different VNID, the Network Policy cannot match the default Ingress
controller.
You must label the default namespace (which have VNID=0) with network.openshift.io/policy-group: ingress to
allow traffic from Ingress
To correctly detect your workload in Kiali, you must have both version and app labels on the pod template of your workload
resource (Deployment, Deploymentconfig, Statefulset, etc).
52
V0000000
Services port labels CONFIDENTIAL designator
Although Istio can detect protocol used by services, sometime it could fail to find the protocol which prevents any
communication to the services.
53
V0000000
CONFIDENTIAL designator
Basic
Configuration
54
V0000000
CONFIDENTIAL designator
55
V0000000
CONFIDENTIAL designator
56
V0000000
CONFIDENTIAL designator
57
V0000000
CONFIDENTIAL designator
58
V0000000
Workloads support in Kiali CONFIDENTIAL designator
By default, Kiali will exclude the following workloads: DeploymentConfig, ReplicationController, Statefulsets, CronJob, Job
59
V0000000
Sidecar Injection (1/3)
CONFIDENTIAL designator
automatically injects the sidecar into pods within the projects you have labeled.
60
V0000000
Sidecar Injection (2/3)
CONFIDENTIAL designator
Red Hat OpenShift Service Mesh does not automatically inject the sidecar to any pods,
but requires you to opt in to injection using an annotation without labeling projects.
This method requires fewer privileges and does not conflict with other OpenShift capabilities such as builder pods.
To enable automatic injection you specify the sidecar.istio.io/inject annotation in the pod template spec.
61
V0000000
Sidecar Injection (3/3)
CONFIDENTIAL designator
If you don’t inject Envoy proxy sidecar container, your pod will not be meshed. It means it will not be managed by the
control plane.
Traffic to / from this non meshed pod will still be controlled by namespace network policies.
62
V0000000
CONFIDENTIAL designator
Traffic
Management
63
V0000000
CONFIDENTIAL designator
Traffic Management
Traffic management decouples traffic flow and infrastructure scaling. This flexibility allows you to use Istio to specify
which rules to apply for traffic management between pods. Envoy manage which pods receive traffic.
makes call to
v1
c
affi
f tr
95%o
MySQL Database
5%
of t
raffi
c
app.example.com
makes call to
v2
A Gateway CR will allow to receive incoming HTTP/TCP connections into the data plane.
You must a configure a Gateway to allow external traffic in your data plane.
65
V0000000
Gateway (2/2)
CONFIDENTIAL designator
In control plane namespace, a Route will be created for every configured hosts in the YAML
Note you will also have to configure at least a VirtualService CR to route the traffic from the gateway to the desired
services in your data plane.
66
V0000000
Virtual Services CONFIDENTIAL designator
A VirtualService defines a set of traffic routing rules to apply when a host is addressed.
Each routing rule defines matching criteria for traffic of a specific protocol.
If the traffic is matched, then it is sent to a named destination service (or subset/version of it) defined in the registry.
You can narrow the hosts to filter the traffic for this Virtual
Services. Hosts can be:
- Services (if traffic come from data plane services)
- Routes FQDN (if traffic come from gateway(s))
67
V0000000
CONFIDENTIAL designator
DestinationRule
Virtual services route traffic to a destination. Destination rules configure what happens to traffic at that destination.
List of subsets.
A subset is a service endpoint for pods with a unique label
to distinguish it from others endpoints of the same
68 service.
Load Balancing can be overridden for a particular
V0000000
subset.
ServiceEntry - Hardening the egress traffic
CONFIDENTIAL designator
By default, the Istio proxy lets calls to unknown services pass through the egress gateway.
If you need to control access to external services you have to configure proxy.networking.trafficControl.outbound.policy
in ServiceMeshControlPlane CR.
You have to create ServiceEntry CRs to lets the traffic pass when hardening to registered service only.
69
V0000000
CONFIDENTIAL designator
You can configure virtual services and destination rules to control traffic to a service entry in the same way you
configure traffic for any other service in the mesh.
70
V0000000
CONFIDENTIAL designator
71
V0000000
Egress Gateway CONFIDENTIAL designator
By default egress traffic exit directly from the istio proxy of the workload calling the external service.
To enforce the egress traffic to exit from the egress gateway, you have to configure the appropriate resources for the egress
gateway.
Gateway CR apply to
Egress Gateway
72
V0000000
Define a subset for each external host (or external hosts group) in the
DestinationRule applying to the egress gateway service.
CONFIDENTIAL designator
Security
73
V0000000
Istio Security CONFIDENTIAL designator
4
Istiod uses the internal certificate authority to sign
and return the identity.
By default, Istio tracks the server workloads migrated to Istio proxies, and configures client proxies to send mutual TLS
traffic to those workloads automatically, and to send plain text traffic to workloads without sidecars.
Thus, all traffic between workloads with proxies uses mutual TLS, without you doing anything.
V0000000
Authentication - Auto mutual TLS (2/2) CONFIDENTIAL designator
While Istio automatically upgrades all traffic between the proxies and the workloads to mutual
TLS between, workloads can still receive plain text traffic.
Secure connections are always used when proxies communicate with the
control plane regardless of spec.security.controlPlane.mtls setting.
This setting is only used when configuring connections for Legacy and deprecated Mixer telemetry or
policy on Service Mesh 1.x.
77
V0000000
PeerAuthentication - Mesh Level (1/2) CONFIDENTIAL designator
Out-of-the box when creating the control plane, 3 PeerAuthentication CR are defined in the control plane namespace.
These PeerAuthentication CR are controlled by the ServiceMeshControlPlane resource, you are not supposed to alter
them directly.
78
V0000000
PeerAuthentication - Mesh Level (2/2) CONFIDENTIAL designator
When Data plane Security is enabled, mTLS mode is set to STRICT to allow
only secure traffic in the mesh
79
V0000000
PeerAuthentication - Namespace & Workload Level (1/2) CONFIDENTIAL designator
In this example policy is set to STRICT for a workload which differs from
PERMISSIVE namespace policy level so we must set the Destination to
ISTIO_MUTUAL to allow only secure traffic.
80
V0000000
PeerAuthentication - Namespace & Workload Level (2/2) CONFIDENTIAL designator
When a service uses an unknown protocol, the Envoy proxy treats the traffic as an opaque TCP connection and
wraps the connection for mTLS.
In some cases, you might need to disable specific ports from mTLS wrapping.
81
V0000000
Security display in Kiali (1/2) CONFIDENTIAL designator
At the right side, Kiali shows a lock when the mesh has strictly enabled mTLS for the whole service mesh.
V0000000
Security display in Kiali (2/2) CONFIDENTIAL designator
A lock when strict mTLS is enabled or a When an edge shows a lock icon it means at least
hollow lock when permissive one request with mTLS enabled is present.
85
V0000000
Transport authentication - Ingress Gateways - SDS method CONFIDENTIAL designator
You can configure a TLS ingress gateway to fetch credentials from the ingress gateway agent via secret discovery service
(SDS).
The ingress gateway agent runs in the same pod as the ingress gateway and watches the credentials created in the same
namespace as the ingress gateway.
AuthorizationPolicy CR enables access control on workloads in the mesh. It supports both allow and deny policies.
Additional conditions of a
87
request V0000000
Authorization - Istio native authorization with JWT CONFIDENTIAL designator
PROS:
● Natively supported by Istio
● Simple to set up (2 CRDs: RequestAuthentication
and AuthorizationPolicy)
● Fine-grained policy based on JWT token
attributes
CONS:
● Token retrieval and embedding left to the user
CODE:
servicemesh-2-rhsso-examples - approach 1
V0000000
Authorization - OIDC workflow using oauth2-proxy CONFIDENTIAL designator
PROS:
● Authentication enforced at the ingress gateway
level
● Automated OIDC workflow to authenticate the
user
CONS:
● Coarse-grained authorization (authenticated ==
authorized)
● Complex, non-native setup (involves ressources
patches)
CODE:
servicemesh-2-rhsso-examples - approach 2
V0000000
Authorization - Combining OIDC workflow with JWT CONFIDENTIAL designator
PROS:
● Authentication enforced at the ingress gateway
level
● Automated OIDC workflow to authenticate the
user
● Can be combined with fine-grained JWT-based
authorization policies
CONS:
● Complex, non-native setup (involves ressources
patches)
CODE:
servicemesh-2-rhsso-examples - approach 3
V0000000
CONFIDENTIAL designator
Observability
91
V0000000
CONFIDENTIAL designator
Observability
Observability is an important characteristic of cloud-native distributed systems that helps you understand, operate, maintain
and evolve the system
92
V0000000
CONFIDENTIAL designator
Observability
There are 3 critical pieces that the Operation team should be aware of:
● Distributed tracing: What happens to each request as it comes in, traversing a set of microservices and goes back as a
response?
○ Which service is causing latency?
○ How much time is take to process each service?
■ Identify the bottleneck and improve the architecture.
● Metrics:
○ How many hits the application has received?
■ Based on metrics we can do capacity planning.
● Visualization:
○ We should be able to visualize graphically, how service are interconnected.
93
V0000000
CONFIDENTIAL designator
Trace the path of a request as it travels across a complex system, discover the latency
Distributed Tracing
Jaeger
of the components along that path, and know which component in the path is creating
a bottleneck.
Monitoring All service-to-service communication goes through Envoy proxies, and the service
Prometheus mesh control plane is able to gather logs and metrics from these proxies.
Helps you define, validate, and observe the connections and microservices of the
Visualization
Kiali
service mesh. It visualizes the service mesh topology and provides visibility into
features such as request routing, circuit breakers, request rates, latency and more.
94
V0000000
Distributed Tracing - Spans & Trace concepts (1/2)
CONFIDENTIAL designator
95
V0000000
Distributed Tracing - Spans & Trace concepts (2/2)
CONFIDENTIAL designator
To be able to effectively trace the ongoing of a request we need two primary things:
● ubiquitousness of the request (availability of tracing mechanism at each microservice)
● what rate sampling the request (tracing all request would put pressure on the resources VS losing request context)
The trace begins when the user sends the Total time of the parent span. Parent span supports a
request and ends when the user receives bunch of child spans.
the response.
Within the request there are spans. A
span denotes an amount of time taken to
complete a particular request.
96
Each span has a unique id and track its direct parent id (pid)
V0000000
Distributed Tracing - Trace Context Propagation (1/2)
CONFIDENTIAL designator
Red Hat OpenShift Service Mesh uses a standard set of HTTP headers for trace context propagation.
The Envoy proxy sidecar tracks these headers and forwards them to Jaeger for storage and analysis.
A service needs to collect and propagate the following headers from incoming request to any outgoing requests:
● x-request-id
● x-b3-traceid
● x-b3-spanid
● x-b3-parentspanid
● x-b3-sampled
● x-b3-flags
● x-ot-span-context
All the services have these identifiers injected which help us to know what is part of the request.
You must explicitly enable tracing in your applications to generate traces and spans and to propagate context
information
97
V0000000
Distributed Tracing - Trace Context Propagation (2/2)
CONFIDENTIAL designator
To enable distributing tracing for Node.js based applications, you must user the jaeger-client and opentracing NPM
packages:
100
V0000000
Distributed Tracing - Enabling in Node.js application example (2/3)
CONFIDENTIAL designator
Add contextual information to the span using the setTag() method (you can add multiple tags to a span):
You can pass any relevant object as an argument,
which will help you to troubleshoot issues as the
request flows accross services in the mesh.
Once the function finished executing, invoke the span.finish() function to end the span:
101
V0000000
Distributed Tracing - Enabling in Node.js application example (3/3)
CONFIDENTIAL designator
When you create a new span using the startSpan() method, it creates a new root span by default.
A request can call multiples services in a certain order.
You must link these different calls using parent child relationships so that Jaeger web console can display the
appropriate service call graph and help you trace the call flow.
To declare a span as a child of another span add the childOf property with a value of the parend span to the startSpan() method
For incoming traffic, to extract contextual information, use the tracer.extract() method:
102
V0000000
CONFIDENTIAL designator
103
V0000000
CONFIDENTIAL designator
Select a service
104
Trace you services V0000000
Distributed Tracing - Jaeger (3/3)
CONFIDENTIAL designator
Click on a trace to
see trace details
105
V0000000
Metrics CONFIDENTIAL designator
106
V0000000
Identifying PassthroughCluster / BlackHoleCluster traffic endpoints (1/2) CONFIDENTIAL designator
107
V0000000
Identifying PassthroughCluster / BlackHoleCluster traffic endpoints (2/2) CONFIDENTIAL designator
In Prometheus mesh instance, you can monitoring the traffic hits by viewing istio_tcp_connections_closed_total metric.
110
V0000000
CONFIDENTIAL designator
Advanced
Configuration
111
V0000000
CONFIDENTIAL designator
- Gateways
- Prometheus
- Grafana
- Kiali
- Jaeger
- Elasticsearch
- Telemetry
112
V0000000
CONFIDENTIAL designator
113
V0000000
CONFIDENTIAL designator
Replace <templates-directory> with the location of the ServiceMeshControlPlane files on your local disk.
115
V0000000
CONFIDENTIAL designator
Limitations
116
V0000000
Limitations - Init Containers
CONFIDENTIAL designator
Because Red Hat Service Mesh use Istio CNI, initcontainers cannot makes network call before Envoy sidecar proxy is
deployed.
V0000000
CONFIDENTIAL designator
Any Questions?
V0000000
CONFIDENTIAL designator
Thank you
Red Hat is the world’s leading provider of enterprise
linkedin.com/company/red-hat facebook.com/redhatinc
youtube.com/user/RedHatVideos twitter.com/RedHat
120
V0000000