https://github.com/piomin/spring-boot-istio
Spring Boot Library for integration with Istio on Kubernetes
https://github.com/piomin/spring-boot-istio
istio kubernetes library service-mesh spring-boot springframework
Last synced: 2 months ago
JSON representation
Spring Boot Library for integration with Istio on Kubernetes
- Host: GitHub
- URL: https://github.com/piomin/spring-boot-istio
- Owner: piomin
- Created: 2020-06-10T13:10:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-21T11:02:00.000Z (12 months ago)
- Last Synced: 2025-04-02T21:39:34.720Z (11 months ago)
- Topics: istio, kubernetes, library, service-mesh, spring-boot, springframework
- Language: Java
- Homepage: https://piotrminkowski.com
- Size: 74.2 KB
- Stars: 50
- Watchers: 3
- Forks: 20
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Spring Boot Library for integration with Istio on Kubernetes [](https://twitter.com/piotr_minkowski)

[](https://circleci.com/gh/piomin/spring-boot-istio)
[](https://sonarcloud.io/dashboard?id=piomin_spring-boot-istio)
[](https://sonarcloud.io/dashboard?id=piomin_spring-boot-istio)
[](https://sonarcloud.io/dashboard?id=piomin_spring-boot-istio)
[](https://sonarcloud.io/dashboard?id=piomin_spring-boot-istio)
## Main Purpose
This library is dedicated for Spring Boot application. Once it is included and enabled it is creating Istio resources on the current Kubernetes cluster basing on the code and annotation fields `@EnableIstio`.
## Getting Started
### Prerequisites
- Java 17 or higher
- Kubernetes cluster with Istio installed
- kubectl configured to access your cluster
### Installation
Add the dependency to your Maven `pom.xml`:
```xml
com.github.piomin
istio-spring-boot-starter
1.2.2
```
## Usage
The library provides autoconfigured support for creating Istio resources on Kubernetes basing on annotation `@EnableIstio`.
```java
@SpringBootApplication
@EnableIstio(version = "v1")
public class CallmeApplication {
public static void main(String[] args) {
SpringApplication.run(CallmeApplication.class, args);
}
}
```
We can enable additional things. For example, we can enable `Gateway` and `VirtualService` with fault injection or matches in `VirtualService`.
```java
@SpringBootApplication
@EnableIstio(enableGateway = true,
fault = @Fault(type = FaultType.ABORT, percentage = 50),
matches = { @Match("/hello"), @Match("/hello2") })
public class SampleAppWithIstio {
public static void main(String[] args) {
SpringApplication.run(SampleAppWithIstio.class, args);
}
}
```
The `@EnableIstio` annotation provides the following configuration options:
| Parameter | Type | Default | Description |
|------------------------|---------|---------|--------------------------------------------------------|
| `version` | String | - | (Required) Version label for the service |
| `numberOfRetries` | int | 3 | Number of retries for failed requests |
| `timeout` | int | 6000 | Request timeout in milliseconds (0 means no timeout) |
| `circuitBreakerErrors` | String | - | Number of errors in row to trip the circuit breaker |
| `weight` | String | 100 | A weight ot path in load balancing |
| `enableGateway` | boolean | false | Enable Istio `Gateway` generation |
| `fault` | Fault | @Fault | Enable Istio fault (delay. abort) injection |
| `matches` | Match[] | {} | Enable multiple matches (e.g. uri, headers) generation |
| `domain` | String | ext | The name of domain used host |
### How It Works
The library automatically creates the following Istio resources during application startup:
`DestinationRule`: Defines policies for traffic routing, including load balancing and connection pool settings.\
`VirtualService`: Configures request routing, retries, timeouts, matches, and fault injection.
`Gateway`: Exposes the service to external traffic.
Here's the architecture of presented solution. Spring Boot Istio Library is included to the target application. It uses Java Istio Client to communication with istiod. During application startup the library is communicating with Istio API in order to create `DestinationRule` and `VirtualService` objects.
