|
| 1 | +## Running Kong Ingress Controller with Istio |
| 2 | + |
| 3 | +In this guide, you will: |
| 4 | +* Install Istio v1.6.7 and Kong in your cluster. |
| 5 | +* Deploy an example Istio-enabled application (_bookinfo_). |
| 6 | +* Deploy an `Ingress` customized with a `KongPlugin` for the example application. |
| 7 | +* Make several requests to the sample application via Kong and Istio. |
| 8 | +* See the performance metrics of the sample application, provided by Istio. |
| 9 | + |
| 10 | +### Prerequisites |
| 11 | +For this guide, you will need: |
| 12 | + |
| 13 | +* A Kubernetes v1.15 (or newer) cluster which can pull container images from public registries. For example, you can use: |
| 14 | + * A managed Kubernetes cluster (AWS EKS, Google Cloud GKE, Azure AKS). |
| 15 | + * Minikube. |
| 16 | + * `microk8s` with the `dns` addon enabled. |
| 17 | +* `kubectl` with admin access to the cluster. |
| 18 | + |
| 19 | +### Download Istio |
| 20 | + |
| 21 | +Download the Istio bundle at version 1.6.7: |
| 22 | + |
| 23 | +```console |
| 24 | +$ curl -L https://istio.io/downloadIstio | env ISTIO_VERSION=1.6.7 sh - |
| 25 | +... |
| 26 | +... |
| 27 | +Istio 1.6.7 Download Complete! |
| 28 | + |
| 29 | +Istio has been successfully downloaded into the istio-1.6.7 folder on your system. |
| 30 | +... |
| 31 | +... |
| 32 | +``` |
| 33 | + |
| 34 | +### Install Istio Operator |
| 35 | + |
| 36 | +Invoke `istioctl` to deploy the Istio Operator to the Kubernetes cluster: |
| 37 | + |
| 38 | +```console |
| 39 | +$ ./istio-1.6.7/bin/istioctl operator init |
| 40 | +Using operator Deployment image: docker.io/istio/operator:1.6.7 |
| 41 | +✔ Istio operator installed |
| 42 | +✔ Installation complete |
| 43 | +``` |
| 44 | + |
| 45 | +### Deploy Istio using Operator |
| 46 | + |
| 47 | +Deploy Istio using Istio Operator: |
| 48 | + |
| 49 | +```console |
| 50 | +$ kubectl create namespace istio-system |
| 51 | +namespace/istio-system created |
| 52 | +``` |
| 53 | +```console |
| 54 | +$ kubectl apply -f - <<EOF |
| 55 | + apiVersion: install.istio.io/v1alpha1 |
| 56 | + kind: IstioOperator |
| 57 | + metadata: |
| 58 | + namespace: istio-system |
| 59 | + name: example-istiocontrolplane |
| 60 | + spec: |
| 61 | + profile: demo |
| 62 | +EOF |
| 63 | +istiooperator.install.istio.io/example-istiocontrolplane created |
| 64 | +``` |
| 65 | +```console |
| 66 | +$ kubectl describe istiooperator -n istio-system |
| 67 | +... |
| 68 | +... |
| 69 | +Status: |
| 70 | + Status: RECONCILING |
| 71 | +... |
| 72 | +... |
| 73 | +``` |
| 74 | + |
| 75 | +Wait until the `kubectl describe istiooperator` command returns `Status: HEALTHY`. |
| 76 | + |
| 77 | +### Deploy Kong Ingress Controller in an Istio-enabled namespace |
| 78 | + |
| 79 | +```console |
| 80 | +$ kubectl create namespace kong-istio |
| 81 | +namespace/kong-istio created |
| 82 | +``` |
| 83 | +```console |
| 84 | +$ kubectl label namespace kong-istio istio-injection=enabled |
| 85 | +namespace/kong-istio labeled |
| 86 | +``` |
| 87 | +```console |
| 88 | +$ helm install -n kong-istio example-kong kong/kong --set ingressController.installCRDs=false |
| 89 | +... |
| 90 | +NAME: example-kong |
| 91 | +LAST DEPLOYED: Mon Aug 10 15:14:44 2020 |
| 92 | +NAMESPACE: kong-istio |
| 93 | +STATUS: deployed |
| 94 | +... |
| 95 | +``` |
| 96 | + |
| 97 | +_Optional:_ Run `kubectl describe pod -n kong-istio -l app.kubernetes.io/instance=example-kong` to see that the Istio sidecar (`istio-proxy`) is running alongside Kong Ingress Controller. |
| 98 | + |
| 99 | +### Deploy bookinfo in an Istio-enabled namespace |
| 100 | + |
| 101 | +Deploy the sample _bookinfo_ app from the Istio bundle: |
| 102 | + |
| 103 | +```console |
| 104 | +$ kubectl create namespace my-istio-app |
| 105 | +namespace/my-istio-app created |
| 106 | +``` |
| 107 | +```console |
| 108 | +$ kubectl label namespace my-istio-app istio-injection=enabled |
| 109 | +namespace/my-istio-app labeled |
| 110 | +kubectl apply -n my-istio-app -f istio-1.6.7/samples/bookinfo/platform/kube/bookinfo.yaml |
| 111 | +``` |
| 112 | +Wait until the application is up: |
| 113 | +```console |
| 114 | +$ kubectl wait --for=condition=Available deployment productpage -n my-istio-app --timeout=240s |
| 115 | +``` |
| 116 | +### Deploy ingress |
| 117 | + |
| 118 | +Define a `KongPlugin` rate-limiting access to 100 requests per minute. Define an `Ingress` telling Kong to proxy traffic |
| 119 | +to a service belonging to the sample application: |
| 120 | + |
| 121 | +```console |
| 122 | +$ kubectl apply -f - <<EOF |
| 123 | +apiVersion: configuration.konghq.com/v1 |
| 124 | +kind: KongPlugin |
| 125 | +metadata: |
| 126 | + name: rate-limit |
| 127 | + namespace: my-istio-app |
| 128 | +plugin: rate-limiting |
| 129 | +config: |
| 130 | + minute: 30 |
| 131 | + policy: local |
| 132 | +EOF |
| 133 | +``` |
| 134 | + |
| 135 | +```console |
| 136 | +$ kubectl apply -f - <<EOF |
| 137 | +apiVersion: extensions/v1beta1 |
| 138 | +kind: Ingress |
| 139 | +metadata: |
| 140 | + name: productpage |
| 141 | + namespace: my-istio-app |
| 142 | + annotations: |
| 143 | + konghq.com/plugins: rate-limit |
| 144 | +spec: |
| 145 | + rules: |
| 146 | + - http: |
| 147 | + paths: |
| 148 | + - path: / |
| 149 | + backend: |
| 150 | + serviceName: productpage |
| 151 | + servicePort: 9080 |
| 152 | +``` |
| 153 | + |
| 154 | +### Make some requests to the sample application |
| 155 | + |
| 156 | +Connect to the sample application served via Kong and Istio. |
| 157 | + |
| 158 | +Note that `8080:80` means that `kubectl` will open the `tcp/8080` port on the local system and forward all requests to |
| 159 | +Kong's port `80`. |
| 160 | + |
| 161 | +```console |
| 162 | +$ # Keep the command below running in the background |
| 163 | +$ kubectl port-forward service/example-kong-kong-proxy 8080:80 -n kong-istio |
| 164 | +Forwarding from 127.0.0.1:8080 -> 8000 |
| 165 | +Forwarding from [::1]:8080 -> 8000 |
| 166 | +... |
| 167 | +``` |
| 168 | + |
| 169 | +Navigate your web browser to `http://localhost:8080/` You should be able to see a bookstore web application. Click |
| 170 | +through any available links several times. As you hit 30 requests per minute (for example, by holding down the "Refresh" |
| 171 | +key combination, e.g. `<Ctrl-R>` or `<Command-R>`), you should obtain a `Kong Error - API rate limit exceeded` response. |
| 172 | + |
| 173 | +### See the connection graph in Kiali |
| 174 | + |
| 175 | +Connect to Kiali (the Istio dashboard): |
| 176 | + |
| 177 | +```console |
| 178 | +$ # Keep the command below running in the background |
| 179 | +$ kubectl port-forward service/kiali 20001:20001 -n istio-system |
| 180 | +Forwarding from 127.0.0.1:20001 -> 20001 |
| 181 | +Forwarding from [::1]:20001 -> 20001 |
| 182 | +... |
| 183 | +``` |
| 184 | + |
| 185 | +* Navigate your web browser to `http://localhost:20001/`. |
| 186 | +* Log in using the default credentials (`admin`/`admin`). |
| 187 | +* Choose _Workloads_ from the menu on the left. |
| 188 | +* Select `my-istio-app` in the _Namespace_ drop-down menu. |
| 189 | +* Click the _productpage-v1_ service name. |
| 190 | +* Click the three dots button in the top-right corner of _Graph Overview_ and click _Show full graph_. |
| 191 | +* Select `kong-istio` alongside `my-istio-app` in the _Namespace_ diagram. |
| 192 | +* Observe a connection graph spanning from `example-kong-kong-proxy` through `productpage-v1` to the other sample |
| 193 | +application services such as `ratings-v1` and `details-v1`. |
| 194 | + |
| 195 | +### See the metrics in Grafana |
| 196 | + |
| 197 | +Connect to Grafana (a dashboard frontend for Prometheus which has been deployed with Istio): |
| 198 | + |
| 199 | +```console |
| 200 | +$ # Keep the command below running in the background |
| 201 | +$ kubectl port-forward service/grafana 3000:3000 -n istio-system |
| 202 | +Forwarding from 127.0.0.1:3000 -> 3000 |
| 203 | +Forwarding from [::1]:3000 -> 3000 |
| 204 | +... |
| 205 | +``` |
| 206 | + |
| 207 | +* Navigate your web browser to `http://localhost:3000/`. |
| 208 | +* Expand the dashboard selection drop-down menu from the top of the screen. Expand the `istio` directory and choose the |
| 209 | +_Istio Workload Dashboard_ from the list. |
| 210 | +* Choose _Namespace: my-istio-app_ and _Workload: productpage-v1_ from the drop-downs. |
| 211 | +* Choose a timespan in the top-right of the page to include the time when you made requests to the sample application (e.g. _Last 1 hour_). |
| 212 | +* Observe the incoming and outgoing request graphs reflecting actual requests from Kong to `productpage-v1`, and from `productpage-v1` to its backends. |
| 213 | + |
| 214 | +Note that the requests from the web browser to Kong are not reflected in inbound stats of `example-kong-kong-proxy` |
| 215 | +because we've issued these requests by `kubectl port-forward`, thus bypassing the Istio proxy sidecar in Kong. |
0 commit comments