• The API Platform for AI.

      Explore More
      Platform Runtimes
      Kong Gateway
      • Kong Cloud Gateways
      • Kong Ingress Controller
      • Kong Operator
      • Kong Gateway Plugins
      Kong AI Gateway
      Kong Event Gateway
      Kong Mesh
      Platform Core Services
      • Gateway Manager
      • Mesh Manager
      • Service Catalog
      Platform Applications
      • Developer Portal
      • API and AI Analytics
      • API Products
      Development Tools
      Kong Insomnia
      • API Design
      • API Testing and Debugging
      Self-Hosted API Management
      Kong Gateway Enterprise
      Kong Open Source Projects
      • Kong Gateway OSS
      • Kuma
      • Kong Insomnia OSS
      • Kong Community
      Get Started
      • Sign Up for Kong Konnect
      • Documentation
    • Featured
      Open Banking SolutionsMobile Application API DevelopmentBuild a Developer PlatformAPI SecurityAPI GovernanceKafka Event StreamingAI GovernanceAPI Productization
      Industry
      Financial ServicesHealthcareHigher EducationInsuranceManufacturingRetailSoftware & TechnologyTransportation
      Use Case
      API Gateway for IstioBuild on KubernetesDecentralized Load BalancingMonolith to MicroservicesObservabilityPower OpenAI ApplicationsService Mesh ConnectivityZero Trust SecuritySee all Solutions
      Demo

      Learn how to innovate faster while maintaining the highest security standards and customer trust

      Register Now
  • Customers
    • Documentation
      Kong KonnectKong GatewayKong MeshKong AI GatewayKong InsomniaPlugin Hub
      Explore
      BlogLearning CentereBooksReportsDemosCase StudiesVideos
      Events
      API SummitWebinarsUser CallsWorkshopsMeetupsSee All Events
      For Developers
      Get StartedCommunityCertificationTraining
    • Company
      About UsWhy Kong?CareersPress RoomInvestorsContact Us
      Partner
      Kong Partner Program
      Security
      Trust and Compliance
      Support
      Enterprise Support PortalProfessional ServicesDocumentation
      Press Release

      Kong Advances Konnect Capabilities to Propel Today’s API Infrastructures into the AI Era

      Read More
  • Pricing
  • Login
  • Get a Demo
  • Start for Free
Blog
  • Engineering
  • Enterprise
  • Learning Center
  • Kong News
  • Product Releases
    • API Gateway
    • Service Mesh
    • Insomnia
    • Kubernetes
    • API Security
    • AI Gateway
  • Home
  • Blog
  • Engineering
  • Kubernetes Ingress gRPC Example With a Dune Quote Service
Engineering
July 30, 2021
6 min read

Kubernetes Ingress gRPC Example With a Dune Quote Service

Viktor Gamov

APIs come in all different shapes and forms. In this tutorial, I'll show you a K8s 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.

I’m using Java to generate a server-side implementation of the service. However, you can take this proto file and implement this service in any language that you use.

Protobuf comes with various tools in different languages, including some code generators that support your language of choice.


Let's take a look at the deployment for our Dune Quote service.

Kubernetes Deployment Review

I'm using the same image in my deployment, but my active service will be using version 3.

My application will be running the GRPC_SERVER on port 9001. And this port will be available to the service to expose this inside my Kubernetes cluster.

My service has security enabled. And I do provide some certificates in the gRPC server private key.

I’m using a self-signed TLS certificate in this example. You'll need to use a certificate signed by a certification authority that you trust in a production use case.

I created the secrets. After that, I mount those secrets as files in my deployment.

Service Review

My service will use port 9001 as my target port. Pay attention to Line 6, where I have the limitation: konghq.com/protocol. It will respond to gRPC as a protocol because my service has security enabled, and I need to notify my Kong Gateway that my service understands gRPCS protocol.


And last but not least, I need to create an ingress.

K8s Ingress Setup

You see some familiar things like ingress.class that corresponds to my open source Kong Ingress Controller. Now, I also have an annotation here: konghq.com/protocols

It's an ingress configuration that allows Kong Gateway to understand what kind of incoming clients we expect. In this case, we’re creating this ingress for gRPCS because we’re expecting gRPC clients to connect to the service. We’re using gRPC or gRPCS protocols.


Before deploying the Kubernetes service, we'll need to set up Kong Ingress Controller and Kubernetes cert-manager.

Ingress Controller and Cert Manager Setup

I've already installed the Kong Ingress Controller. If you haven't, follow along in my previous getting started tutorial.

I configured my cluster to use cert-manager. I will be using certificates issued by LetsEncrypt. In Kong's documentation, there is a getting started guide for cert-manager that allows you to configure your Kong Ingress Controller and your API Gateway to use automatically issued certificates for TLS.

Next, we need to follow the Kubernetes cert-manager documentation.

Then, we'll be able to request the TLS certificate from the certification authority. And after that, the application will use port 443 TLS to communicate with external clients.

That’s why I have this annotation, kubernetes.io/tls-acme, to use an automatic certificate management extension enabled for my cluster. I’m using the LetsEncrypt server production version to receive the certificate.

The next thing is to configure my ingress. I need to specify that I’m using TLS for my ingress and issue a certificate for this domain name. This domain name corresponds to the external IP address that Google Cloud Platform provided.

It’s the same configuration rules for the particular path. By default, that will correspond to my Dune Quote service.

Inbound traffic will listen on gRPC or gRPCS protocols. My Kong Gateway and Dune Quote service will also use the gRPCS protocol because I deployed my service using gRPCS.

The next thing is to configure my ingress. I need to specify that I’m using TLS for my ingress and issue a certificate for this domain name. This domain name corresponds to the external IP address that Google Cloud Platform provided.

It’s the same configuration rules for the particular path. By default, that will correspond to my Dune Quote service.

Inbound traffic will listen on gRPC or gRPCS protocols. My Kong Gateway and Dune Quote service will also use the gRPCS protocol because I deployed my service using gRPCS.

Deploy the Kubernetes Service

Before we can deploy, we need to provide two secrets.

We can provide the secrets with the below script. It generates a self-signed certificate and after that, applies this certificate and key as my secrets.


Next, let's restart the deployment and bring up our service.

Test the Service

Once our service is up, we can use Insomnia to hit the service.

In Insomnia, let's upload our proto file. Once that's uploaded, we'll see two methods, GetQuote and GetQuoteStream.

When we hit GetQuote, we get some quotes from Dune. It works!

Next, let’s see if streaming works by switching to the GetQuoteStream. When I click Start, my response contains 10 responses from the gRPCS server. Nice!

And my implementation has an interceptor that will log all the calls to my service.

That's a Wrap!

In this article, I showed you how to deploy a gRPC service to Kubernetes and expose it outside of the cluster using Kong Ingress Controller.

Once you've finished this Kubernetes Ingress gRPC example, you may find these other Kubernetes tutorials helpful:

  • Configuring a Kubernetes Application on Kong Konnect
  • Managing Docker Apps With Kubernetes Ingress Controller
  • Implementing Traffic Policies in Kubernetes
  • What is CI/CD?

Have questions or want to stay in touch with the Kong community? Join us wherever you hang out:

⭐ Star us on GitHub

🐦 Follow us on Twitter

🌎 Join the Kong Community

🍻 Join our Meetups

❓ ️Ask and answer questions on Kong Nation

💯 Apply to become a Kong Champion

Topics:Kubernetes
|
gRPC
|
Ingress
Powering the API world

Increase developer productivity, security, and performance at scale with the unified platform for API management, service mesh, and ingress controller.

Sign up for Kong newsletter

Platform
Kong KonnectKong GatewayKong AI GatewayKong InsomniaDeveloper PortalGateway ManagerCloud GatewayGet a Demo
Explore More
Open Banking API SolutionsAPI Governance SolutionsIstio API Gateway IntegrationKubernetes API ManagementAPI Gateway: Build vs BuyKong vs PostmanKong vs MuleSoftKong vs Apigee
Documentation
Kong Konnect DocsKong Gateway DocsKong Mesh DocsKong Insomnia DocsKong Plugin Hub
Open Source
Kong GatewayKumaInsomniaKong Community
Company
About KongCustomersCareersPressEventsContactPricing
  • Terms•
  • Privacy•
  • Trust and Compliance
  • © Kong Inc. 2025