GithubHelp home page GithubHelp logo

alts-go-grpc-envoy's Introduction

ALTS Go gRPC with Envoy

In this experiment, we evaluate gRPC authentication in Go using Application Layer Transport Security (ALTS).

To have a comprehensive overview of how ALTS works take a look at the gRPC ALTS authentication doc page. To have an in-depth understanding of its concepts and design take a look at the ALTS whitepaper

Quick ALTS Overview

ALTS is used for gRPC service-to-service authentication for applications running on Google Cloud infrastructure. ALTS will use the server's identity, usually the instance service account, to establish the encrypted communication.

The image below shows a visual explanation of how ALTS works:

About this Code

In this example, we deploy three services to GKE and establish a secure communication between two of them. See the image below for more details.

The checkout service uses Envoy as sidecar to handle egress traffic and, instead of implementing the client ALTS credentials, we use the type.googleapis.com/envoy.extensions.transport_sockets.alts.v3.Alts config to allow the client to authenticate with the server.

Notice that since the three services are deployed to the same GKE cluster and all nodes have the same Service Account, we don't need to explicitly provide the service account in the ALTS configuration.

Running the Code

To run this code

Create a GKE cluster and configure your kubeconfig to access the new cluster

gke_cluster=my-cluster
gke_zone=us-central1-a

gcloud container clusters $gke_cluster --num-nodes 3 --zone $gke_zone
gcloud container get-credentials $gke_cluster --zone $gke_zone

Deploy the services to GKE

kubectl create ns checkout

for s in shipping payment checkout; do
  kubectl apply -f "$s"/.kube.yaml -n checkout
done

Before running the client, expose the checkout service port

kubectl port-forward $(kubectl get pods -n checkout -l app=checkout -o jsonpath="{.items[0].metadata.name}") 50054:50054 -n checkout
# keep this session running

Run the client

cd client
go build
go run main.go

Re-building things

If you make changes to the code, re-build and push the new image. Example:

cd checkout
docker build -t your_dockerhub_account/alts-checkout:v1 .
docker push your_dockerhub_account/alts-checkout:v1

# Remember to update the image in the .kube.yaml file and apply 

If you make changes in the protobuf, re-build it:

# Install the protoc in a local folder
./install_protoc_grpc_go.sh

# Generate the stubs for all services
./protogen

A note on GKE Workload Identity

As per today, it seems that ALTS does not support the workload identity feature.

References

These are some resources that helped me during this experiment:

alts-go-grpc-envoy's People

Contributors

soeirosantos avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.