Skip to content

Commit 4f9058b

Browse files
tjonsashutosh-narkar
authored andcommitted
update istio envoy tutorial to use AuthorizationPolicy
Signed-off-by: tjons <[email protected]>
1 parent 7a32e8f commit 4f9058b

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

docs/content/envoy-tutorial-istio.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,23 @@ weight: 11
55
---
66

77
[Istio](https://istio.io/latest/) is an open source service mesh for managing the different microservices that make
8-
up a cloud-native application. Istio provides a mechanism to customize the Envoy configuration generated by Istio Pilot
9-
using [EnvoyFilter](https://istio.io/latest/docs/reference/config/networking/envoy-filter/).
8+
up a cloud-native application. Istio provides a mechanism to use a service as an external authorizer with the
9+
[AuthorizationPolicy API](https://istio.io/latest/docs/tasks/security/authorization/authz-custom/).
1010

11-
This tutorial shows how Istio's EnvoyFilter can be configured to include Envoy's [External Authorization
12-
filter](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/security/ext_authz_filter.html) to delegate
13-
authorization decisions to OPA.
11+
This tutorial shows how Istio's AuthorizationPolicy can be configured to delegate authorization decisions to OPA.
1412

1513
## Prerequisites
1614

1715
This tutorial requires Kubernetes 1.20 or later. To run the tutorial locally ensure you start a cluster with Kubernetes
1816
version 1.20+, we recommend using [minikube](https://kubernetes.io/docs/getting-started-guides/minikube) or
1917
[KIND](https://kind.sigs.k8s.io/).
2018

21-
The tutorial also requires Istio v1.8.0 or later. It assumes you have Istio deployed on top of Kubernetes.
19+
The tutorial also requires Istio v1.19.0 or later. It assumes you have Istio deployed on top of Kubernetes.
2220
See Istio's [Quick Start](https://istio.io/docs/setup/kubernetes/install/kubernetes/) page to get started.
2321

22+
If you are using an earlier version of Istio (1.9+), you will have to customize the `AuthorizationPolicy` in the
23+
`quick_start.yaml` file to use the `security.istio.io/v1beta1` API version instead of `security.istio.io/v1`.
24+
2425
## Steps
2526

2627
### 1. Install OPA-Envoy
@@ -31,7 +32,9 @@ kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/opa-envoy-p
3132

3233
The `quick_start.yaml` manifest defines the following resources:
3334

34-
* External Authorization Filter to direct authorization checks to the OPA-Envoy sidecar. See `kubectl -n istio-system get envoyfilter ext-authz` for details.
35+
* AuthorizationPolicy to direct authorization checks to the OPA-Envoy sidecar. See `kubectl -n {$NAMESPACE} get authorizationpolicy ext-authz` for details.
36+
37+
* ServiceEntry to allow Istio to find the OPA-Envoy sidecars. See `kubectl -n {$NAMESPACE} get serviceentry opa-ext-authz-grpc-local` for details.
3538

3639
* Kubernetes namespace (`opa-istio`) for OPA-Envoy control plane components.
3740

@@ -128,14 +131,32 @@ The `quick_start.yaml` manifest defines the following resources:
128131
> API](https://www.openpolicyagent.org/docs/latest/bundles/). ConfigMaps are
129132
> used in this tutorial for test purposes.
130133
131-
### 2. Enable automatic injection of the Istio Proxy and OPA-Envoy sidecars in the namespace where the app will be deployed, e.g., `default`
134+
### 2. Configure the mesh to define the external authorizer
135+
136+
Edit the mesh configmap with `kubectl edit configmap -n istio-system istio` and define the external provider:
137+
138+
```yaml
139+
data:
140+
mesh: |-
141+
# Add the following lines to define the ServiceEntry previously created as an external authorizer:
142+
extensionProviders:
143+
- name: opa-ext-authz-grpc
144+
envoyExtAuthzGrpc:
145+
service: opa-ext-authz-grpc.local
146+
port: "9191"
147+
```
148+
149+
See [the Istio Docs for AuthorizationPolicy](https://istio.io/latest/docs/tasks/security/authorization/authz-custom/#define-the-external-authorizer) for
150+
more details.
151+
152+
### 3. Enable automatic injection of the Istio Proxy and OPA-Envoy sidecars in the namespace where the app will be deployed, e.g., `default`
132153

133154
```bash
134155
kubectl label namespace default opa-istio-injection="enabled"
135156
kubectl label namespace default istio-injection="enabled"
136157
```
137158

138-
### 3. Deploy the BookInfo application and make it accessible outside the cluster
159+
### 4. Deploy the BookInfo application and make it accessible outside the cluster
139160

140161
```bash
141162
kubectl apply -f https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/platform/kube/bookinfo.yaml
@@ -145,7 +166,7 @@ kubectl apply -f https://raw.githubusercontent.com/istio/istio/master/samples/bo
145166
kubectl apply -f https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/networking/bookinfo-gateway.yaml
146167
```
147168

148-
### 4. Set the `SERVICE_HOST` environment variable in your shell to the public IP/port of the Istio Ingress gateway
169+
### 5. Set the `SERVICE_HOST` environment variable in your shell to the public IP/port of the Istio Ingress gateway
149170

150171
Run this command in a new terminal window to start a Minikube tunnel that sends traffic to your Istio Ingress Gateway:
151172

@@ -171,7 +192,7 @@ export SERVICE_HOST=$(kubectl -n istio-system get service istio-ingressgateway -
171192
For other platforms see the [Istio documentation on determining ingress IP and ports.](https://istio.io/docs/tasks/traffic-management/ingress/#determining-the-ingress-ip-and-ports)
172193

173194

174-
### 5. Exercise the OPA policy
195+
### 6. Exercise the OPA policy
175196

176197
Check that **alice** can access `/productpage` **BUT NOT** `/api/v1/products`.
177198

0 commit comments

Comments
 (0)