Install Istio for Google Cloud Endpoints Services
This document shows how to manually integrate Istio with existing Google Cloud Endpoints services.
Before you begin
If you don't have an Endpoints service and want to try it out, you can follow
the instructions
to setup an Endpoints service on GKE.
After setup, you should be able to get an API key and store it in ENDPOINTS_KEY
environment variable and the external IP address EXTERNAL_IP
.
You may test the service using the following command:
$ curl --request POST --header "content-type:application/json" --data '{"message":"hello world"}' "http://${EXTERNAL_IP}:80/echo?key=${ENDPOINTS_KEY}"
To install Istio for GKE, follow our Quick Start with Google Kubernetes Engine.
HTTP Endpoints service
Inject the service into the mesh using
--includeIPRanges
by following the instructions so that Egress is allowed to call external services directly. Otherwise, ESP won't be able to access Google cloud service control.After injection, issue the same test command as above to ensure that calling ESP continues to work.
If you want to access the service through Ingress, create the following Ingress definition:
cat <<EOF | kubectl apply -f - apiVersion: extensions/v1beta1 kind: Ingress metadata: name: simple-ingress annotations: kubernetes.io/ingress.class: istio spec: rules: - http: paths: - path: /echo backend: serviceName: esp-echo servicePort: 80 EOF
Get the Ingress IP and port by following the instructions. You can verify accessing the Endpoints service through Ingress:
$ curl --request POST --header "content-type:application/json" --data '{"message":"hello world"}' "http://${INGRESS_HOST}:${INGRESS_PORT}/echo?key=${ENDPOINTS_KEY}"i
HTTPS Endpoints service using secured Ingress
The recommended way to securely access a mesh Endpoints service is through an ingress configured with mutual TLS.
Expose the HTTP port in your mesh service. Adding
"--http_port=8081"
in the ESP deployment arguments and expose the HTTP port:- port: 80 targetPort: 8081 protocol: TCP name: http
Turn on mutual TLS in Istio by using the following command:
$ kubectl edit cm istio -n istio-system
And uncomment the line:
authPolicy: MUTUAL_TLS
After this, you will find access to
EXTERNAL_IP
no longer works because istio proxy only accept secure mesh connections. Accessing through Ingress works because Ingress does HTTP terminations.To secure the access at Ingress, follow the instructions.
You can verify accessing the Endpoints service through secure Ingress:
$ curl --request POST --header "content-type:application/json" --data '{"message":"hello world"}' "https://${INGRESS_HOST}/echo?key=${ENDPOINTS_KEY}" -k
HTTPS Endpoints service using LoadBalancer EXTERNAL_IP
This solution uses Istio proxy for TCP bypassing. The traffic is secured through ESP. This is not a recommended way.
Modify the name of the HTTP port to be
tcp
- port: 80 targetPort: 8081 protocol: TCP name: tcp
Update the mesh service deployment. See further readings on port naming rules in Requirements for Pods and Services.
You can verify access to the Endpoints service through secure Ingress:
$ curl --request POST --header "content-type:application/json" --data '{"message":"hello world"}' "https://${EXTERNAL_IP}/echo?key=${ENDPOINTS_KEY}" -k