Find out how to install Istio as a standalone program on clusters you've created with Kubernetes Engine (OKE).
This topic provides an example of how to install Istio as a standalone program on clusters you've created with Kubernetes Engine (OKE). In addition, key features of OKE and Istio are demonstrated.
Note that service mesh products (such as Oracle Cloud Infrastructure Service Mesh, Istio, and Linkerd) are supported when using the OCI VCN-Native Pod Networking CNI plugin for pod networking. Note that, with the exception of the Istio add-on, support is currently limited to Oracle Linux 7 (Oracle Linux 8 support is planned). The Istio add-on is supported with both Oracle Linux 7 and Oracle Linux 8. Worker nodes must be running Kubernetes 1.26 (or later).
Note
You can use Istio with managed node pools, but not with virtual node pools.
Installing Istio as a Standalone Program
To get started using Istio, create an OKE cluster or use an existing OKE cluster, then
install Istio. The sections provided below discuss the steps to install and test your
Istio setup. For a complete list of installation options, see
here.
Creating an OKE cluster
Create an OKE cluster.
If you have not already done so, create an OKE cluster within your OCI tenancy.
Multiple options are available to create an OKE cluster . The
simplest option is the Quick Create wizard in the web console.
To access the OKE cluster on your local machine, install kubectl and oci-cli .
Access the OKE cluster from the command line using
kubectl by setting up the kubeconfig file
and ensure that kubectl can access the cluster.
Downloading Istio from the Command Line
Follow these steps to download Istio from the command line.
Download Istio by running the following command:
Copy
curl -L https://istio.io/downloadIstio | sh -
Move to the Istio package directory. For example, if the package is
istio-1.11.2:
Copy
cd istio-1.11.2
Add the istioctl client tool to the PATH for
your workstation.
Copy
export PATH=$PWD/bin:$PATH
Validate if the cluster meets Istio install requirements by running the
precheck:
Copy
istioctl x precheck
Installing Istio with istioctl
Install Istio with istioctl using the following command:
Copy
istioctl install
Running the Bookinfo Application 🔗
The Istio project provides the Bookinfo application as a way to demonstrate Istio
features. The application displays information about a book, similar to a single
catalog entry of an online book store. Each book page contains a description of the
book, details about the book (ISBN, number of pages), and a few book reviews. For more information on the Bookinfo application, see the Bookinfo docs here.
As you can see from the diagram, the Bookinfo application is composed of four
microservices.
Product Page Service: Calls the Details and Reviews
services to create a product page.
Details Service: Returns book information.
Reviews Service: Returns book reviews and calls the Ratings
service.
Ratings Service: Returns ranking information for a book review.
To install and run the Bookinfo application, follow these steps.
Label the namespace that hosts the application with
istio-injection=enabled.
Also, open the URL
http://${INGRESS_HOST}:${INGRESS_PORT}/productpage in a browser
to view the Bookinfo web page. Refresh the page several times to see different
versions of reviews shown on the product page.
Adding Istio Integration Applications
Istio integrates well with several popular Kubernetes related applications.
Prometheus
Istio provides a basic sample installation to quickly get Prometheus up and
running.
Copy
kubectl apply -f samples/addons/prometheus.yaml
Alternatively, install prometheus and configure it to scrape Istio metrics.
In this section, explore the performance metrics and tracing features provided by the
Istio integration applications.
Querying Metrics from Prometheus for Bookinfo application
With Prometheus and Istio, the Bookinfo performance data is analyzed in several
ways.
First, verify that Prometheus is installed.
Copy
kubectl -n istio-system get svc prometheus
Start the Prometheus UI with the following command:
Copy
istioctl dashboard prometheus
Click Graph to the right of Prometheus in the header. To see some data, generate
traffic for product page using a browser or curl. The traffic is
reflected in the Prometheus dashboard.
For more on querying Prometheus, read the Istio querying
docs.
Visualizing Metrics for Bookinfo Application with Grafana
Combining Prometheus with Grafana provides some nice performance dashboards for
applications. To use the dashboards, first verify that both Prometheus and Grafana
are installed.
Copy
kubectl -n istio-system get svc prometheus
kubectl -n istio-system get svc grafana
Start the Istio Grafana dashboard.
Copy
istioctl dashboard grafana
Managing Grafana Dashboards
The Istio service mesh delivers six Grafana dashboards. The Istio service mesh
Grafana dashboard snapshots are captured here.
Note
Generate traffic to the product page using a browser or curl and
see it reflected in the Grafana dashboard.
Istio Mesh Dashboard
Istio Service Dashboard
Istio Workload Dashboard
Istio Performance Dashboard
Istio Control Pane Dashboard
For more on how to create, configure, and edit dashboards, see the Grafana
documentation.
Performing Distributed Tracing using Jaeger
Use the Jaeger open source framework to perform application tracing with Istio.
With the Bookinfo application deployed, open the zipkin UI using
istioctl.
Copy
istioctl dashboard zipkin
To generate traces, send in requests to the product page.
Copy
for i in $(seq 1 100); do curl -s -o /dev/null "http://$INGRESS_HOST:$INGRESS_PORT/productpage"; done
You see that the traces reflect in the zipkin dashboard.
Sample zipkin Dashboard
Performing Distributed Tracing with OCI Application Performance Monitoring
OCI Application Performance Monitoring (APM) integrates with open source tracing system tools such as Jaeger and zipkin. APM enables you to upload trace data in OCI. To integrate with OCI APM, create an APM domain by following the instructions mentioned here. An APM domain is an OCI resource which contains the systems monitored by APM.
After the domain is created, view the domain details and obtain the data upload endpoint, private key, and public key to construct the APM Collector URL. The APM collector URL is required when configuring open source tracers to communicate with the APM service. The Collector URL format requires a URL constructed using the data upload endpoint as the base URL and generates the path based on choices including values from our private or public key. The format is documented here. With the URL path constructed, plug the URL into the Istio config.
Note
For more detailed information on configuring APM service policies, see:
The endpoint address of aaaabbbb.apm-agt.us-ashburn-1.oci.oraclecloud.com is an example and not an actual endpoint.
Configure Envoy to send the zipkin traces to APM. Replace the code in samples/custom-bootstrap/custom-bootstrap.yaml with the following code block.
Copy
apiVersion: v1
kind: ConfigMap
metadata:
name: istio-custom-bootstrap-config
namespace: default
data:
custom_bootstrap.json: |
{
"tracing": {
"http": {
"name": "envoy.tracers.zipkin",
"typed_config": {
"@type": "type.googleapis.com/envoy.config.trace.v3.ZipkinConfig",
"collector_cluster": "aaaabbbb.apm-agt.us-ashburn-1.oci.oraclecloud.com", // [Replace this with data upload endpoint of your apm domain]
"collector_endpoint": "/20200101/observations/private-span?dataFormat=zipkin&dataFormatVersion=2&dataKey=2C6YOLQSUZ5Q7IGN", // [Replace with the private datakey of your apm domain. You can also use public datakey but change the observation type to public-span]
"collectorEndpointVersion": "HTTP_JSON",
"trace_id_128bit": true,
"shared_span_context": false
}
}
},
"static_resources": {
"clusters": [{
"name": "aaaabbbb.apm-agt.us-ashburn-1.oci.oraclecloud.com", // [Replace this with data upload endpoint of your apm domain:443]
"type": "STRICT_DNS",
"lb_policy": "ROUND_ROBIN",
"load_assignment": {
"cluster_name": "aaaabbbb.apm-agt.us-ashburn-1.oci.oraclecloud.com", // [Replace this with data upload endpoint of your apm domain]
"endpoints": [{
"lb_endpoints": [{
"endpoint": {
"address": {
"socket_address": {
"address": "aaaabbbb.apm-agt.us-ashburn-1.oci.oraclecloud.com", // [Replace this with data upload endpoint of your apm domain]
"port_value": 443
}
}
}
}]
}]
},
"transport_socket": {
"name": "envoy.transport_sockets.tls",
"typed_config": {
"@type": "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext",
"sni": "aaaabbbb.apm-agt.us-ashburn-1.oci.oraclecloud.com" // [Replace this with data upload endpoint of your apm domain]
}
}
}]
}
}
EOF
For all our services in Bookinfo to use this custom bootstrap configuration, add an annotation sidecar.istio.io/bootstrapOverride with the name of custom ConfigMap as the value. In the following example, an annotation is added for product page under samples/bookinfo/platform/kube/bookinfo.yaml. Add a similar annotation to other services.
To enable an ingress-gateway to send traces, create a configmap named custom-bootstrap.yaml in the istio-system namespace:
Copy
apiVersion: v1
kind: ConfigMap
metadata:
name: istio-custom-bootstrap-config
namespace: istio-system
data:
custom_bootstrap.json: |
{
"tracing": {
"http": {
"name": "envoy.tracers.zipkin",
"typed_config": {
"@type": "type.googleapis.com/envoy.config.trace.v3.ZipkinConfig",
"collector_cluster": "aaaabbbb.apm-agt.us-ashburn-1.oci.oraclecloud.com", // [Replace this with data upload endpoint of your apm domain]
"collector_endpoint": "/20200101/observations/private-span?dataFormat=zipkin&dataFormatVersion=2&dataKey=2C6YOLQSUZ5Q7IGN", // [Replace with the private datakey of your apm domain. You can also use public datakey but change the observation type to public-span]
"collectorEndpointVersion": "HTTP_JSON",
"trace_id_128bit": true,
"shared_span_context": false
}
}
},
"static_resources": {
"clusters": [{
"name": "aaaabbbb.apm-agt.us-ashburn-1.oci.oraclecloud.com", // [Replace this with data upload endpoint of your apm domain:443]
"type": "STRICT_DNS",
"lb_policy": "ROUND_ROBIN",
"load_assignment": {
"cluster_name": "aaaabbbb.apm-agt.us-ashburn-1.oci.oraclecloud.com", // [Replace this with data upload endpoint of your apm domain]
"endpoints": [{
"lb_endpoints": [{
"endpoint": {
"address": {
"socket_address": {
"address": "aaaabbbb.apm-agt.us-ashburn-1.oci.oraclecloud.com", // [Replace this with data upload endpoint of your apm domain]
"port_value": 443
}
}
}
}]
}]
},
"transport_socket": {
"name": "envoy.transport_sockets.tls",
"typed_config": {
"@type": "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext",
"sni": "aaaabbbb.apm-agt.us-ashburn-1.oci.oraclecloud.com" // [Replace this with data upload endpoint of your apm domain]
}
}
}]
}
}
EOF
Create a patch named gateway-patch.yaml for the ingress-gateway to start using custom-bootstrap config:
To generate traces, send in requests to the product page.
Copy
for i in $(seq 1 100); do curl -s -o /dev/null "http://$INGRESS_HOST:$INGRESS_PORT/productpage"; done
You see that the traces reflect in the APM dashboard by following the steps here.
Zipkin Trace Explorer
Zipkin Trace
Zipkin Spans
To see the spans, click Home in the APM list.
Zipkin App Dashboard
APM provides functionality to create dashboards and explore the spans generated over time. Dashboards can be created by following the steps here.
Zipkin Metrics Explorer
APM allows you to monitor the health, capacity, and performance of your applications by using metrics, alarms, and notifications. Follow to steps here to configure metrics.
Observing Logs with OCI Logging
OCI Logging is a central component for analyzing and searching log file
entries for tenancies in OCI. Kubernetes container logs from OKE worker nodes can be
published as custom logs to OCI Logging. Follow the steps described here to configure OCI Logging to ingest container
logs.
Enable envoy access logging in Istio with istioctl.
Access the Bookinfo product page using a browser or curl. The generated access
logs can be viewed using the kubectl command.
Copy
kubectl logs -l app=productpage -c istio-proxy
If OCI Logging is configured for the cluster, these logs can be queried and analyzed
using OCI console's log search page.
OCI Logging Search
OCI Logging Search Expanded
Visualizing Mesh Using Kiali
Verify that Kiali is installed.
Copy
kubectl -n istio-system get svc kiali
Open the Kiali UI in the browser.
Copy
istioctl dashboard kiali
Send some traffic to the product page.
Copy
for i in $(seq 1 100); do curl -s -o /dev/null "http://$INGRESS_HOST:$INGRESS_PORT/productpage"; done
Visualize your mesh in Kiali by following step 5 from here.
Managing Traffic 🔗
Istio's traffic routing rules lets you control the flow of traffic between services and simplifies configuration of service-level properties like circuit breakers, timeouts, and retries. Istio makes it easy to set up important tasks like A/B testing, canary rollouts, and staged rollouts with percentage-based traffic splits.
For Istio to control the Bookinfo application version routing, define all the available
versions of your service, called subsets, in destination rules. Create default
destination rules for the Bookinfo services:
Istio allows us to migrate traffic gradually from one version of a microservice to another version using Istio's weighted routing feature. The following example shows how to configure to send 50% of traffic to reviews:v1 and 50% to reviews:v3. After that, complete the migration by sending 100% of traffic to reviews:v3.
Route all traffic to the v1 version of each microservice.
To view the Bookinfo web page, open the URL
http://${INGRESS_HOST}:${INGRESS_PORT}/productpage in a
browser. Notice that the reviews part of the
page displays with no rating stars, no matter how many times you refresh.
Istio is configured to route all traffic for the reviews service to
reviews:v1 and this version of the service does not
access the star ratings service.
Transfer 50% of the traffic from reviews:v1 to
reviews:v3 with the following command, and wait for the new
rules to propagate.
Refresh the /productpage URL in your browser and see red
colored star ratings approximately 50% of the time. The
reviews:v3 accesses the star ratings service, but the
reviews:v1 version does not.
To view the Bookinfo web page, open the URL
http://${INGRESS_HOST}:${INGRESS_PORT}/productpage in a browser
. Notice that the reviews part of the page displays with no rating stars, no matter
how many times you refresh. Because Istio is configured to route all traffic for the
reviews service to the version reviews:v1. This version of the
service does not access the star ratings service.
Routing based on User Identity
To route based on user identity:
Change the route configuration so that all traffic from a specific user named jason is routed to reviews:v2. Istio doesn't have any special, built-in understanding of user identity. In this example, the productpage service adds a custom end-user header to all outbound HTTP requests to the reviews service.
To view the Bookinfo web page and login as user jason, open
the URL http://${INGRESS_HOST}:${INGRESS_PORT}/productpage
in a browser. Refresh the browser to see that star ratings appear next to
each review.
Open the URL
http://${INGRESS_HOST}:${INGRESS_PORT}/productpage in a
browser to view the Bookinfo web page and login as user other than
jason. Refresh the browser to see no stars for each
review.
Routing based on URL Rewriting
In this example, HTTP requests with a path that starts with
/products or /bookinfoproductpage are
rewritten to /productpage. HTTP requests are sent to pods with
productpage running on port 9080. For more information on Istio
URL rewriting, see here.
To view the Bookinfo web page, open the URL
http://${INGRESS_HOST}:${INGRESS_PORT}/products and
http://${INGRESS_HOST}:${INGRESS_PORT}/bookinfoproductpage
in a browser. In both the cases, a rewrite is performed before forwarding
the request.
Rewrite /bookproductpage
Rewrite /products
Clean up the yaml file to the original version provided by Istio and apply it.
Open the URL
http://${INGRESS_HOST}:${INGRESS_PORT}/bookinfoproductpage
or http://${INGRESS_HOST}:${INGRESS_PORT}/products to not
see the product page because the yaml doesn't rewrite the request.
404 Error /products
404 Error /booksproductpage
Testing Network Resilience
Istio allows you to configure your installation for request timeouts, fault
injection, and circuit breakers. These settings allow manage and test the fault
tolerance of deployed applications.
Setting Request Timeouts
A timeout is the amount of time an Envoy proxy waits for replies from a given
service. The timeout ensures that services don't wait for replies indefinitely and
ensures that calls succeed or fail within a predictable timeframe. For more information on timeouts, see here.
A timeout for HTTP requests can be specified using the timeout field of the route rule. By default, the request timeout is disabled.
Initialize the application version routing by running the following command:
To view the Bookinfo web page with ratings stars displayed, open the URL http://${INGRESS_HOST}:${INGRESS_PORT}/productpage
in a browser . A
2-second delay occurs whenever you refresh the page.
Add a half second request timeout for calls to the reviews service:
To view the Bookinfo web page, open the URL
http://${INGRESS_HOST}:${INGRESS_PORT}/productpage in a
browser. Notice the page returns in about 1
second, instead of 2, and the reviews are unavailable.
The reason that the response takes 1 second, even though the timeout is configured at
half a second, is because a hard-coded retry in the productpage
service. The service calls the timed out reviews service twice before returning.
In addition to overriding them in route rules, the timeout can also be overridden on
a per-request basis if the application adds an
x-envoy-upstream-rq-timeout-ms header on outbound requests.
Managing Fault Injection
Fault injection is a testing method that introduces errors into a system to ensure
that the system withstands and recovers from error conditions. Istio allows fault
injection at the application layer such as HTTP error codes. Istio injects two types
of faults, both configured using a virtual service. For more information on fault injection, see here.
Delays: Delays are timing failures that mimic increased network latency
or an overloaded upstream service.
Aborts: Aborts are crash failures that mimic failures in upstream
services. Aborts manifest in the form of HTTP error codes or TCP connection
failures.
To test fault injection, run the following command to initialize the application
version routing:
Create a fault injection rule to delay traffic coming from the user
jason. The following command injects a 7-second delay
between the reviews:v2 and ratings microservices for user
jason.
The reviews:v2 service has a 10-s hard-coded connection
timeout for calls to the ratings service. With 7-second delay, expect the
end-to-end flow to continue without any errors.
To view the Bookinfo web page, open the URL
http://${INGRESS_HOST}:${INGRESS_PORT}/productpage in a
browser.
The Bookinfo home page loads without any errors in approximately seven
seconds. However, the reviews section displays an error message: Sorry,
product reviews are currently unavailable for this book. A bug
exists in the application code. The hard-coded timeout between the
productpage and the reviews service
results in a 6-second delay, 3 seconds plus 1 retry. As a result, the
productpage call to reviews times out
prematurely and throws an error after 6 seconds.
To fix the bug, increase the productpage to
reviews service timeout, or decrease the
reviews to ratings timeout to less
than 3 seconds.
Let's fix the bug by adding a 2-second delay to the ratings service for user jason.
Now that the bug is fixed, open the URL
http://${INGRESS_HOST}:${INGRESS_PORT}/productpage in a
browser to view the Bookinfo web page. Sign in as jason with
ratings stars displayed.
Injecting an HTTP Abort Fault
Follow these steps to inject an abort fault:
Create a fault injection rule to send an HTTP abort response for user
jason:
To view the Bookinfo web page, open the URL http://${INGRESS_HOST}:${INGRESS_PORT}/productpage
in a browser. Login as user
jason. A message indicates the ratings service
is unavailable.
Logout from user jason or login with any other user to not
see any error message.
Creating Circuit Breakers
Circuit breaking allows us to write applications that limit the impact of failures,
latency spikes, and other undesirable effects of network peculiarities. For more
information on circuit breakers, see here.
Create a destination rule to apply circuit breaking settings when calling the
product service. The following rule sets the maximum number of connections to be
not more than one and have a maximum of one HTTP pending requests. In addition,
the rules configure hosts to be scanned every 1 second. Any host that fails one
time with a 5XX error code is ejected for 3 minutes. Also, 100% of hosts in the
load balancing pool for the upstream service are ejected.
Create a client to send traffic to the product service. Fortio lets you control
the number of connections, concurrency, and delays for outgoing HTTP calls. If
you have enabled automatic sidecar injection, deploy the fortio
service:
Only 26.7% of the requests succeeded and circuit breaking traps the rest.
Copy
11:10:19 I logger.go:127> Log level is now 3 Warning (was 2 Info)
Fortio 1.11.3 running at 0 queries per second, 128->128 procs, for 30 calls: http://productpage:9080
Starting at max qps with 3 thread(s) [gomax 128] for exactly 30 calls (10 per thread + 0)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
11:10:19 W http_client.go:693> Parsed non ok code 503 (HTTP/1.1 503)
Ended after 28.105508ms : 30 calls. qps=1067.4
Aggregated Function Time : count 30 avg 0.0024256753 +/- 0.003264 min 0.000261072 max 0.010510116 sum 0.07277026
# range, mid point, percentile, count
>= 0.000261072 <= 0.001 , 0.000630536 , 66.67, 20
> 0.001 <= 0.002 , 0.0015 , 73.33, 2
> 0.005 <= 0.006 , 0.0055 , 76.67, 1
> 0.006 <= 0.007 , 0.0065 , 83.33, 2
> 0.007 <= 0.008 , 0.0075 , 93.33, 3
> 0.009 <= 0.01 , 0.0095 , 96.67, 1
> 0.01 <= 0.0105101 , 0.0102551 , 100.00, 1
# target 50% 0.000805545
# target 75% 0.0055
# target 90% 0.00766667
# target 99% 0.0103571
# target 99.9% 0.0104948
Sockets used: 25 (for perfect keepalive, would be 3)
Jitter: false
Code 200 : 8 (26.7 %)
Code 503 : 22 (73.3 %)
Response Header Sizes : count 30 avg 44.533333 +/- 73.85 min 0 max 167 sum 1336
Response Body/Total Sizes : count 30 avg 670.06667 +/- 711.5 min 241 max 1850 sum 20102
All done 30 calls (plus 0 warmup) 2.426 ms avg, 1067.4 qps
Query the istio-proxy stats to gain more information.
Traffic mirroring, also called shadowing, allows teams to bring changes to production
with as little risk as possible. Mirroring sends a copy of live traffic to a
mirrored service. The mirrored traffic occurs outside of the critical request path
for the primary service.
Route all traffic to the v1 version of each microservice.
The previous route rule sends 100% of the traffic to reviews:v1 and mirrors 100% of the same traffic to the reviews:v2 service.
When traffic gets mirrored, the requests are sent to the mirrored service with their Host/Authority headers appended with -shadow. For example, reviews become reviews-shadow.Mirrored requests considered as "fire and forget." The mirrored responses are discarded.
Instead of mirroring all requests, change the value field under the mirrorPercentage field to mirror a fraction of the traffic. If this field is absent, all traffic is mirrored.
Send in some traffic by refreshing the url
http://${INGRESS_HOST}:${INGRESS_PORT}/productpage in a
browser.
Logs of reviews:v1 service. Note v1 service does not call the
ratings service.
Logs of reviews:v2 mirrored service. Note for the v2 service,
the header is appended with -shadow.
Managing Gateways
Gateway describes a load balancer operating at the edge of the mesh receiving
incoming or outgoing HTTP/TCP connections. Gateway configurations are applied to
standalone Envoy proxies that are running at the edge of the mesh, rather than
sidecar Envoy proxies running alongside your service workloads. Istio provides some
preconfigured gateway proxy deployments istio-ingressgateway and
istio-egressgateway.
If you haven't setup the Istio gateways as part of the installation, run the
following command to install them.
Copy
istioctl install
The command deploys Istio using the default settings which includes a gateway. For
more information, see
here.
The ingress gateway configures exposed ports and protocols, but unlike Kubernetes
Ingress Resources, does not include any traffic routing configuration. Traffic
routing for ingress traffic is instead configured using Istio routing rules. For
more information on Istio ingress, see here.
Note
If you have already deployed the Bookinfo application, the following steps are not
required.
Create an Istio gateway that configures on port 80 for HTTP traffic.
Access any other URL that has not been explicitly exposed. You see an HTTP 404
error.
Copy
curl -s -I http://$INGRESS_HOST:$INGRESS_PORT/any
The command produces the following output:
HTTP/1.1 404 Not Found
date: Tue, 07 Sep 2021 13:49:45 GMT
server: istio-envoy
transfer-encoding: chunked
For explicit hosts in gateways, use the -H flag to set the Host HTTP header. The
flag is needed because your ingress gateway and virtual service are configured
to handle the host. For example, your host is example.com and the name is
specified in both gateways and virtual service.
Also, open the URL
http://${INGRESS_HOST}:${INGRESS_PORT}/productpage in a
browser to view the Bookinfo web page.
Configuring Ingress using Kubernetes Ingress Resource
The reader assumes that Bookinfo application is deployed into the cluster. To
deploy the Bookinfo application, see the
"Running the Bookinfo Application" section of the Installing Istio and OKE page.
Remove the Istio gateway if the configuration is already applied.
By default, all outbound traffic from an Istio enabled pod is redirected to its
sidecar proxy and Istio configures the Envoy proxy to pass through requests for
unknown services. Istio configures the sidecar handling of external services through
a configuration field meshConfig.outboundTrafficPolicy.mode. If
this option is set to:
This step is required only if you have explicitly set the option to
REGISTRY_ONLY during the installation.
To confirm successful 200 responses, make a request to external services from
the SOURCE_POD:
Copy
export SOURCE_POD=$(kubectl get pod -l app=ratings -o jsonpath='{.items..metadata.name}')
kubectl exec $SOURCE_POD -c ratings -- curl -sI http://httpbin.org/headers | grep "HTTP"
The command produces the following output:
HTTP/1.1 200 OK
However, the drawback with this approach is that Istio monitoring and control for
traffic to external services is lost.
Controlling Access to External Services [Recommended]
To set up controlled access to external services, follow these steps:
Change the meshConfig.outboundTrafficPolicy.mode option to
REGISTRY_ONLY. This step is required only if you haven't
explicitly set the option to REGISTRY_ONLY during the
installation.
Follow only step 1 from the "Envoy Passthrough to External Services" section.
The only change to make here is that replace ALLOW_ANY with
REGISTRY_ONLY.
To verify that the external services are blocked, make a couple of requests to
external HTTPS services from the SOURCE_POD. Configuration
changes take several seconds to propagate, so successful connections are
possible. Wait for several seconds and then retry the last command.
Copy
export SOURCE_POD=$(kubectl get pod -l app=ratings -o jsonpath='{.items..metadata.name}')
kubectl exec $SOURCE_POD -c ratings -- curl -sI http://httpbin.org/headers | grep "HTTP"
The command produces the following output:
HTTP/1.1 502 Bad Gateway
Create a ServiceEntry to allow access to an external HTTP service.
For accessing HTTPS calls, replace the port and protocol when creating service
entries.
The approach adds external service traffic management features like timeouts and
fault injection. The following request returns 200 (OK) in approximately five
seconds.
This approach bypasses the Istio sidecar proxy, giving services direct access to any external server. However, configuring the proxy this way does require cluster-provider specific knowledge and configuration. Similar to the first approach, we lose monitoring of access to external services and can't apply Istio features on traffic to external services. Follow these steps to provide direct access to external services.
Securing Istio 🔗
The Istio security features provide strong identity, powerful policy, transparent TLS encryption, and authentication, authorization, and audit (AAA) tools to protect your services and data.
Configuring Authentication
Istio offers mutual TLS as a full-stack solution for transport authentication, which is enabled without requiring service code changes.
Deploy sleep and httpbin services in the default namespace.
By default, Istio performs several tasks. Istio tracks the server workloads migrated to Istio proxies. Istio configures client proxies to send mutual TLS traffic to those workloads automatically. Istio sends plain text traffic to workloads without sidecars.
To verify that certs are sent, send a request from a sleep pod to httpbin pod and look
for the X-Forwarded-Client-Cert header.
Copy
kubectl exec "$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})" -c sleep -- curl -s http://httpbin.default:8000/headers -s | grep X-Forwarded-Client-Cert | sed 's/Hash=[a-z0-9]*;/Hash=<redacted>;/'
Deploy another instance of the sleep and httpbin services without the sidecar
enabled.
The request from the sleep pod in the default namespace to httpbin pod in the legacy
namespace is plaintext because the destination is not sidecar enabled. Verify that plain text is sent by running the following command.
Copy
kubectl exec "$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})" -c sleep -- curl http://httpbin.legacy:8000/headers -s | grep X-Forwarded-Client-Cert
The request from the sleep pod in the legacy namespace to httpbin in the default
namespace also succeeds with a plaintext connection. The can be verified with the
following
command.
Copy
kubectl exec "$(kubectl get pod -l app=sleep -n legacy -o jsonpath={.items..metadata.name})" -n legacy -c sleep -- curl http://httpbin.default:8000/headers
To prevent non-mutual TLS traffic for the whole mesh, set a mesh-wide peer
authentication policy with the mutual TLS mode set to STRICT.
Istio allows you to configure authorization policies for your applications.
First, configure a simple allow-nothing policy that rejects all
requests to the workload, and then grants more access to the workload gradually and
incrementally.
You see the "Bookinfo Sample" page but the productpage service cannot access the details and reviews page.
Add the following policies to grant productpage workload access to the details and reviews workloads and reviews workload access to the ratings workload.
We can expose the Bookinfo application as a secure HTTPS service using either simple or mutual TLS. To sign the certificates for your services, create a root certificate and private key: