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

  1. 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.

  2. After injection, issue the same test command as above to ensure that calling ESP continues to work.

  3. 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
  4. 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.

  1. 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
  2. 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
  3. 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.

  4. To secure the access at Ingress, follow the instructions.

  5. 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.

  1. Modify the name of the HTTP port to be tcp

    - port: 80
      targetPort: 8081
      protocol: TCP
      name: tcp
  2. Update the mesh service deployment. See further readings on port naming rules in Requirements for Pods and Services.

  3. 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