In this tutorial, I’ll explain how to deploy a gRPC service to Kubernetes and provide external access to the service using Kong’s Ingress Controller.

image

Kong Hacker Noon profile picture

@kongincKong

Build apps faster with the API, Ingress, and Service Mesh Connectivity Platform.

APIs come in all different shapes and forms. In this tutorial, I’ll show you a Kubernetes Ingress gRPC example. I’ll explain how to deploy a gRPC service to Kubernetes and provide external access to the service using Kong’s Kubernetes Ingress Controller.

And to hype you up a little bit about the upcoming live-action movie, Dune, based on Frank Herbert’s book, I created a Kubernetes service that delivers Dune quotes. It’s arguably one of the most outstanding science fiction books ever written…what do you think? Let me know @GAMUSSA on Twitter.

Before we dive into the code, let’s review a few basics.

How Does gRPC Work With Kong?

gRPC is a procedural framework initially developed by Google in 2015. Based on HTTP2 protocol for transport and Protocol Buffer (Protobuf) as the interface definition language, gRPC has seen growing adoption in recent years. gRPC has several capabilities that traditional REST APIs struggle with, such as bidirectional streaming and efficient binary encoding.

Kong supports TCP streams and can proxy any protocol built on top of a TCP or TLS. We felt that native support for gRPC would allow a growing user base to leverage Kong to manage their REST and gRPC services uniformly.

Now that we’ve covered the basics, let’s take a look at the Protobuf definition of my Dune Quote service.

Protobuf Definition

My Protobuf definition contains a quote service that uses two methods. One method is to deliver a simple quote on any gRPC request. That method doesn’t require any input parameter, so we’ll be using the Protobuf empty type. And as a return, it will have a quote message that will include a message field.

And another method that I have here is a GetQuoteStream method that also doesn’t require any parameters to provide. In this case, I also used an empty type. But in this case, I’m returning a stream of these results.

syntax = "proto3";
 
package io.kong.developer.quoteservice;
 
import "google/protobuf/empty.proto";
 
option java_multiple_files = true;
option java_package = "io.kong.developer.quoteservice";
 
service QuoteService {
 
  rpc GetQuote(google.protobuf.Empty) returns (QuoteMessage) ;
  
  rpc...

Continue reading: https://hackernoon.com/building-a-dune-quote-service-using-kubernetes-ingress-grpc-aa3m37j0?source=rss

Source: hackernoon.com