Installing Anthos Service Mesh on attached clusters

This guide explains how to do a clean installation of Anthos Service Mesh version 1.6.14-asm.2 on GKE Enterprise attached clusters. Use this guide to install Anthos Service Mesh on the following environments:

  • Amazon Elastic Kubernetes Service (Amazon EKS) on Kubernetes version 1.16
  • Microsoft Azure Kubernetes Service (Microsoft AKS) on Kubernetes version 1.16

The installation enables the supported features on your cluster for the asm-multicloud configuration profile.

Before you begin

Requirements

  • The user cluster that you install Anthos Service Mesh on has at least 4 vCPUs, 15 GB memory, and 4 replicas.

  • The cluster doesn't have Anthos Service Mesh or open source Istio installed.

  • To be included in the service mesh, service ports must be named, and the name must include the port's protocol in the following syntax: name: protocol[-suffix] where the square brackets indicate an optional suffix that must start with a dash. For more information, see Naming service ports.

Restrictions

A Google Cloud project can only have one mesh associated with it.

Setting up your environment

You need the following tools on the machine you want to install Anthos Service Mesh from. Note that you can install Anthos Service Mesh only on a user cluster, not an admin cluster.

After installing the Google Cloud CLI:

  1. Authenticate with the Google Cloud CLI:

    gcloud auth login
    
  2. Update the components:

    gcloud components update
    
  3. Install kubectl:

    gcloud components install kubectl
    
  4. Install the required version of kpt:

       curl -L https://github.com/GoogleContainerTools/kpt/releases/download/v0.39.2/kpt_linux_amd64 > kpt_0_39_2
       chmod +x kpt_0_39_2
       alias kpt="$(readlink -f kpt_0_39_2)"
    
  5. Switch context to your user cluster:

    kubectl config use-context CLUSTER_NAME
  6. Grant cluster admin permissions to your user account (your Google Cloud login email address). You need these permissions to create the necessary role based access control (RBAC) rules for Anthos Service Mesh:

    kubectl create clusterrolebinding cluster-admin-binding \
      --clusterrole=cluster-admin \
      --user=USER_ACCOUNT

Preparing to install Anthos Service Mesh

    Linux

  1. Download the Anthos Service Mesh installation file to your current working directory:
    curl -LO https://storage.googleapis.com/gke-release/asm/istio-1.6.14-asm.2-linux-amd64.tar.gz
  2. Download the signature file and use openssl to verify the signature:
    curl -LO https://storage.googleapis.com/gke-release/asm/istio-1.6.14-asm.2-linux-amd64.tar.gz.1.sig
    openssl dgst -verify /dev/stdin -signature istio-1.6.14-asm.2-linux-amd64.tar.gz.1.sig istio-1.6.14-asm.2-linux-amd64.tar.gz <<'EOF'
    -----BEGIN PUBLIC KEY-----
    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWZrGCUaJJr1H8a36sG4UUoXvlXvZ
    wQfk16sxprI2gOJ2vFFggdq3ixF2h4qNBt0kI7ciDhgpwS8t+/960IsIgw==
    -----END PUBLIC KEY-----
    EOF

    The expected output is: Verified OK

  3. Extract the contents of the file to any location on your file system. For example, to extract the contents to the current working directory:
    tar xzf istio-1.6.14-asm.2-linux-amd64.tar.gz

    The command creates an installation directory in your current working directory named istio-1.6.14-asm.2 that contains:

    • Sample applications in the samples directory.
    • The istioctl command-line tool that you use to install Anthos Service Mesh is in the bin directory.
    • The Anthos Service Mesh configuration profiles are in the manifests/profiles directory.

  4. Mac OS

  5. Download the Anthos Service Mesh installation file to your current working directory:
    curl -LO https://storage.googleapis.com/gke-release/asm/istio-1.6.14-asm.2-osx.tar.gz
  6. Download the signature file and use openssl to verify the signature:
    curl -LO https://storage.googleapis.com/gke-release/asm/istio-1.6.14-asm.2-osx.tar.gz.1.sig
    openssl dgst -sha256 -verify /dev/stdin -signature istio-1.6.14-asm.2-osx.tar.gz.1.sig istio-1.6.14-asm.2-osx.tar.gz <<'EOF'
    -----BEGIN PUBLIC KEY-----
    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWZrGCUaJJr1H8a36sG4UUoXvlXvZ
    wQfk16sxprI2gOJ2vFFggdq3ixF2h4qNBt0kI7ciDhgpwS8t+/960IsIgw==
    -----END PUBLIC KEY-----
    EOF

    The expected output is: Verified OK

  7. Extract the contents of the file to any location on your file system. For example, to extract the contents to the current working directory:
    tar xzf istio-1.6.14-asm.2-osx.tar.gz

    The command creates an installation directory in your current working directory named istio-1.6.14-asm.2 that contains:

    • Sample applications in the samples directory.
    • The istioctl command-line tool that you use to install Anthos Service Mesh is in the bin directory.
    • The Anthos Service Mesh configuration profiles are in the manifests/profiles directory.

  8. Windows

  9. Download the Anthos Service Mesh installation file to your current working directory:
    curl -LO https://storage.googleapis.com/gke-release/asm/istio-1.6.14-asm.2-win.zip
  10. Download the signature file and use openssl to verify the signature:
    curl -LO https://storage.googleapis.com/gke-release/asm/istio-1.6.14-asm.2-win.zip.1.sig
    openssl dgst -verify - -signature istio-1.6.14-asm.2-win.zip.1.sig istio-1.6.14-asm.2-win.zip <<'EOF'
    -----BEGIN PUBLIC KEY-----
    MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWZrGCUaJJr1H8a36sG4UUoXvlXvZ
    wQfk16sxprI2gOJ2vFFggdq3ixF2h4qNBt0kI7ciDhgpwS8t+/960IsIgw==
    -----END PUBLIC KEY-----
    EOF

    The expected output is: Verified OK

  11. Extract the contents of the file to any location on your file system. For example, to extract the contents to the current working directory:
    tar xzf istio-1.6.14-asm.2-win.zip

    The command creates an installation directory in your current working directory named istio-1.6.14-asm.2 that contains:

    • Sample applications in the samples directory.
    • The istioctl command-line tool that you use to install Anthos Service Mesh is in the bin directory.
    • The Anthos Service Mesh configuration profiles are in the manifests/profiles directory.

  12. Ensure that you're in the Anthos Service Mesh installation's root directory.
    cd istio-1.6.14-asm.2
  13. For convenience, add the tools in the /bin directory to your PATH:
    export PATH=$PWD/bin:$PATH

Create the istio-system namespace

Create a namespace called istio-system for the control plane components:

kubectl create namespace istio-system

Configure the validating webhook

When you install Anthos Service Mesh, you set a revision label on istiod. You need to set the same revision on the validating webhook.

Copy the following YAML to a file called istiod-service.yaml:

apiVersion: v1
kind: Service
metadata:
  name: istiod
  namespace: istio-system
  labels:
    istio.io/rev: asm-1614-2
    app: istiod
    istio: pilot
    release: istio
spec:
  ports:
    - port: 15010
      name: grpc-xds # plaintext
      protocol: TCP
    - port: 15012
      name: https-dns # mTLS with k8s-signed cert
      protocol: TCP
    - port: 443
      name: https-webhook # validation and injection
      targetPort: 15017
      protocol: TCP
    - port: 15014
      name: http-monitoring # prometheus stats
      protocol: TCP
  selector:
    app: istiod
    istio.io/rev: asm-1614-2

Installing Anthos Service Mesh

  1. Run the following command to install Anthos Service Mesh using the asm-multicloud profile. If you want to enable a supported optional feature, include -f and the YAML filename on the following command line. See Enabling optional features for more information.

    istioctl install \
      --set profile=asm-multicloud \
      --set revision=asm-1614-2
    

    The --set revision argument adds a revision label in the format istio.io/rev=asm-1614-2 to istiod. The revision label is used by the automatic sidecar injector webhook to associate injected sidecars with a particular istiod revision. To enable sidecar auto-injection for a namespace, you must label it with a revision that matches the label on istiod.

  2. Configure the validating webhook so that it can locate the istiod service with the revision label:

    kubectl apply -f istiod-service.yaml
    

    This command creates a service entry that lets the validating webhook automatically check configurations before they are applied.

Auto mutual TLS (auto mTLS) is enabled by default. With auto mTLS, a client sidecar proxy automatically detects if the server has a sidecar. The client sidecar sends mTLS to workloads with sidecars and sends plain text traffic to workloads without sidecars.

Check the control plane components

Check that the control plane pods in istio-system are up:

kubectl get pod -n istio-system

Expected output is similar to the following:

NAME                                   READY   STATUS      RESTARTS   AGE
istio-ingressgateway-cff9f5c7d-qg4ls   1/1     Running   0          7m5s
istio-ingressgateway-cff9f5c7d-vlkzb   1/1     Running   0          7m20s
istiod-66b587859c-886gx                1/1     Running   0          7m33s
istiod-66b587859c-dfs2j                1/1     Running   0          7m33s

If the output of the command shows that one or more components aren't in a Running state, refer to Troubleshooting GKE Enterprise on attached clusters for a script that you can run to get details about the components.

Injecting sidecar proxies

Anthos Service Mesh uses sidecar proxies to enhance network security, reliability, and observability. With Anthos Service Mesh, these functions are abstracted away from the application's primary container and implemented in a common out-of-process proxy delivered as a separate container in the same Pod.

Before you deploy workloads, make sure to configure sidecar proxy injection so that Anthos Service Mesh can monitor and secure traffic.

Any workloads that were running on your cluster before you installed Anthos Service Mesh need to have the sidecar proxy injected or updated so they have the current Anthos Service Mesh version. Before you deploy new workloads, make sure to configure sidecar proxy injection so that Anthos Service Mesh can monitor and secure traffic.

To enable sidecar auto-injection, you label your namespaces with the same revision that you set on istiod. Run the following command to show the labels on istiod:

kubectl -n istio-system get pods -l app=istiod --show-labels

Confirm that the revision label, istio.io/rev=asm-1614-2, is in the output. This is the label that you use to enable auto-injection. You can enable auto-injection with one command, for example:

kubectl label namespace NAMESPACE istio-injection-istio.io/rev=asm-1614-2 --overwrite

where NAMESPACE is the name of the namespace for your application's services or default if you didn't explicitly create a namespace.

For more information, see Injecting sidecar proxies.

Deploying a sample application

Anthos Service Mesh provides a preconfigured ingress gateway, the istio-ingressgateway, that you can use to manage inbound traffic to applications running on your service mesh. To make applications accessible from outside of your cluster, (such as from a browser):

  • You need to get the external IP address of the istio-ingressgateway.

  • Your application must define a Gateway and VirtualService resource, similar to the Online Boutique sample application's frontend-gateway.yaml.

To deploy and run the sample application

  1. Download the sample:

    kpt pkg get \
    https://github.com/GoogleCloudPlatform/microservices-demo.git/release \
    microservices-demo
    
  2. Enable automatic sidecar injection:

    kubectl label namespace default istio-injection=enabled
    
  3. Deploy the sample to the cluster:

    kubectl apply -f microservices-demo
    

To get the external IP address of the istio-ingressgateway:

  1. Create the host key environment variable:

    Microsoft AKS

      export HOST_KEY="ip"
    

    Amazon EKS

      export HOST_KEY="hostname"
    
  2. Create the INGRESS_HOST environment variable:

    export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].'"$HOST_KEY"'}')
    
  3. Create the INGRESS_PORT environment variable:

    export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
    
  4. Visit the application on your browser. In the following URL, replace EXTERNAL_IP with $INGRESS_HOST:$INGRESS_PORT:

    http://EXTERNAL_IP/

When you're finished exploring, remove the sample:

kubectl delete -f microservices-demo