Cloud Native 16 min read

Building a Spring Boot Microservice Demo with gRPC and Istio on Kubernetes

This article provides a step‑by‑step guide to creating a simple Spring Boot microservice that uses gRPC for communication, integrates with Istio as a service mesh, containerizes the applications with Docker, and deploys both server and client to a Kubernetes cluster with full configuration files and code examples.

IT Architects Alliance
IT Architects Alliance
IT Architects Alliance
Building a Spring Boot Microservice Demo with gRPC and Istio on Kubernetes

As a strong advocate of Service Mesh and cloud‑native technologies, the author builds a minimal Spring Boot microservice demo that sends and returns a simple string, choosing Istio over Spring Cloud for service governance and gRPC for inter‑service communication.

Why use Istio? Istio decouples governance logic from business code by running sidecar proxies, eliminating SDK coupling, supporting multi‑language services, and integrating smoothly with Kubernetes.

Why use gRPC? gRPC offers lightweight, high‑performance RPC with Protobuf and HTTP/2, works well with Istio, and avoids the complexities of Spring Cloud’s service‑governance SDKs.

The project is structured with three Maven modules: spring-boot-istio-api , spring-boot-istio-server , and spring-boot-istio-client . The parent pom.xml includes dependencies for Spring Boot, grpc-all , and plugins for building Docker images.

A hello.proto file defines the gRPC service: syntax = "proto3"; option java_package = "site.wendev.spring.boot.istio.api"; option java_outer_classname = "HelloWorldService"; package helloworld; service HelloWorld { rpc SayHello (HelloRequest) returns (HelloResponse) {} } message HelloRequest { string name = 1; } message HelloResponse { string message = 1; }

Server implementation includes a Spring Bean HelloServiceImpl extending HelloWorldGrpc.HelloWorldImplBase and a GrpcServerConfiguration that starts the gRPC server on a configurable port, with a CommandLineRunner to launch it during Spring Boot startup.

Client implementation provides GrpcClientConfiguration to create a channel and stub, and a HelloController exposing a /hello endpoint that calls the gRPC service. A corresponding GrpcClientCommandLineRunner starts and shuts down the client.

Dockerfiles for both server and client are based on openjdk:8u121-jdk , set the timezone, copy the built JAR, define environment variables for ports, and specify the entrypoint.

Kubernetes manifests are provided for Services and Deployments of both server and client, exposing HTTP and gRPC ports, and for an Istio Gateway and VirtualService that route external traffic to the client’s /hello path.

Deployment steps include building Docker images with Maven, applying the YAML files, waiting for pods to become ready, and testing the endpoint via curl http://${GATEWAY_URL}/hello , which should return a greeting like "Hello, JiangWen. This message comes from gRPC."

All source code is available on GitHub at https://github.com/WenDev/spring-boot-istio-demo .

DockerMicroservicesKubernetesgRPCSpring Bootistio
IT Architects Alliance
Written by

IT Architects Alliance

Discussion and exchange on system, internet, large‑scale distributed, high‑availability, and high‑performance architectures, as well as big data, machine learning, AI, and architecture adjustments with internet technologies. Includes real‑world large‑scale architecture case studies. Open to architects who have ideas and enjoy sharing.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.