Skip to content
8 changes: 7 additions & 1 deletion kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ There are 2 instances of Spring Boot Admin available. Both use the discovery mec
there is no self registration used. One SBA is using the spring cloud kubernetes-client and the other one
the spring cloud kubernetes-fabric8. There are small differences in the configuration between these two versions.

There is also a version using the spring cloud kubernetes discovery server to get all running services instead of using
kubernetes discovery directly.

This Readme will guide you through all setup steps for the infrastructure.

## Enable Kubernetes in Docker Desktop
Expand Down Expand Up @@ -37,7 +40,7 @@ helm version
- <https://helm.sh/docs/intro/quickstart/>

## Install Everything
You can run the whole build and installation for all apps with the following script or follow the step by step guide below.
You can run the whole build and installation for all apps with the following script or follow the step-by-step guide below.
```bash
chmod u+x buildAndInstallAll.sh
./buildAndInstallAll.sh
Expand All @@ -47,6 +50,8 @@ http://localhost/spring-boot-admin-kubernetes

http://localhost/spring-boot-admin-fabric8

http://localhost/spring-boot-admin-discoveryclient

## Step-by-step Installation

### Install Traefik
Expand All @@ -58,6 +63,7 @@ http://localhost/spring-boot-admin-fabric8
- [./apps/hello-world/README.md](./apps/hello-world/README.md)
- [./apps/spring-boot-admin-kubernetes/README.md](./apps/spring-boot-admin-kubernetes/README.md)
- [./apps/spring-boot-admin-fabric8/README.md](./apps/spring-boot-admin-fabric8/README.md)
- [./apps/spring-boot-admin-discoveryclient/README.md](./apps/spring-boot-admin-discoveryclient/README.md)
- [./apps/health-simulator/README.md](./apps/health-simulator/README.md)

## Uninstall Everything
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/apps/health-simulator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ You can change the number of replicas in [deployment/values.yaml](deployment/val

## Build & Install Script

You can run the whole build and installation with the following script or follow the step by step guide below.
You can run the whole build and installation with the following script or follow the step-by-step guide below.

```bash
chmod u+x buildAndInstall.sh
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/apps/hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Build & Install Script

You can run the whole build and installation with the following script or follow the step by step guide below.
You can run the whole build and installation with the following script or follow the step-by-step guide below.

```bash
chmod u+x buildAndInstall.sh
Expand Down
5 changes: 5 additions & 0 deletions kubernetes/apps/spring-boot-admin-discoveryclient/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target
.idea
*.iml
*.log
*.gz
8 changes: 8 additions & 0 deletions kubernetes/apps/spring-boot-admin-discoveryclient/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# https://hub.docker.com/_/eclipse-temurin/
FROM eclipse-temurin:17

VOLUME /tmp

COPY target/app.jar /opt/app/app.jar

CMD ["bash", "-c", "java $JAVA_OPTS -jar /opt/app/app.jar"]
70 changes: 70 additions & 0 deletions kubernetes/apps/spring-boot-admin-discoveryclient/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Spring Boot Admin

This is a Spring Boot Admin instance using spring-cloud-starter-kubernetes-discoveryclient for service discovery.
Therefore, it needs a running spring-cloud-kubernetes-discoveryserver.
For this reason, the SBA server does not need kubernetes api permissions on kubernetes itself and uses the
spring-boot-app helmchart.


TODO does not add new services that are started after this one, seems is no Watch like in the other discovery clients.
This also means that it does not add itself to the list of services.


Make sure [discoveryserver](../../helm-charts/spring-cloud-kubernetes-discoveryserver/README.md) is running before deploying this app.


## Build & Install Script

You can run the whole build and installation with the following script or follow the step-by-step guide below.

```bash
chmod u+x buildAndInstall.sh
./buildAndInstall.sh
```

## Step-by-step build

### Build App
```bash
mvn clean install
```

### Build Docker Image
```bash
docker build --tag spring-boot-admin:discocli .
```

### Install App
We use the standard "app" helm chart here and NOT the "admin" helm chart as we do not need the k8s api access with this
setup. The discoveryserver has the permissions and is providing the apps via rest api.

```bash
helm upgrade --install spring-boot-admin-discoveryclient ../../helm-charts/spring-boot-app -f deployment/values.yml
```

### Check deployment
```bash
kubectl get pods -o wide
kubectl get services -o wide
kubectl get ingress
```

### Uninstall
```bash
helm uninstall spring-boot-admin-discoveryclient
```

## URI

- http://localhost/spring-boot-admin-discoveryclient (requires [traefik](../../helm-charts/traefik/README.md) to be running)

## Access Actuator
```bash
kubectl get pods
```
```bash
kubectl port-forward <pod-name> 8081:8081
```
### URI

- http://localhost:8081/actuator
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# Build App
mvn clean install
# Build Docker Image
docker build --tag spring-boot-admin:discocli .
# Install App
helm upgrade --install spring-boot-admin-discoveryclient ../../helm-charts/spring-boot-app -f deployment/values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: spring-boot-admin-discoveryclient
namespace: default

deployment:
server:
port: 8080
management:
port: 8081
image: spring-boot-admin:discocli
88 changes: 88 additions & 0 deletions kubernetes/apps/spring-boot-admin-discoveryclient/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.1</version>
</parent>

<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-discoveryclient</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<version>1.0.0-SNAPSHOT</version>
<description>Spring Boot Admin</description>

<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-boot-admin.version>3.2.1-SNAPSHOT</spring-boot-admin.version>
<spring-cloud.version>2023.0.0</spring-cloud.version>
</properties>

<!-- Kubernetes Discovery -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- Spring Boot Admin -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>${spring-boot-admin.version}</version>
</dependency>

<!-- Kubernetes Discovery -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-discoveryclient</artifactId>
</dependency>
</dependencies>

<build>
<finalName>app</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
<!-- Build-Infos for Info-Actuator -->
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- GIT-Infos for Info-Actuator -->
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<configuration>
<offline>true</offline>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package de.codecentric.springbootadmin;

import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableAdminServer
@EnableScheduling
public class SpringBootAdminApplication {

public static void main(String... args) {
var app = new SpringApplication(SpringBootAdminApplication.class);
// Buffering for Startup-Actuator
app.setApplicationStartup(new BufferingApplicationStartup(2048));
app.run();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
server:
port: 8080
spring:
application: # Application-Infos for the Info-Actuator
name: "@pom.artifactId@"
# Spring Boot Admin
boot:
admin:
ui:
title: ${SPRING_BOOT_ADMIN_UI_TITLE:Spring Boot Admin}
brand: <img src="assets/img/icon-spring-boot-admin.svg"><span>${SPRING_BOOT_ADMIN_UI_TITLE:Spring Boot Admin}</span>
discovery: # Filter discovery to tagged services
instances-metadata:
spring-boot-admin: true # is added as annotation in service.yaml in helm chart
cloud:
kubernetes:
discovery:
all-namespaces: true
include-not-ready-addresses: true
discovery-server-url: "http://spring-cloud-kubernetes-discoveryserver"
# for local development (starting directly from IDE), enable port forwarding for discovery server and use the following
# three lines instead of the one above
# discovery-server-url: "http://localhost:8761"
# main:
# cloud-platform: KUBERNETES
management: # Actuator Configuration
server:
port: 8081
endpoints:
web:
exposure:
include: "*"
endpoint: # Health-Actuator
health:
show-details: always
probes:
enabled: true
env: # Environment-Actuator
show-values: always
configprops: # Configuration-Actuator
show-values: always
info: # Info-Actuator
java:
enabled: true
os:
enabled: true
build:
enabled: true
env:
enabled: true
git:
enabled: true
info: # Application-Infos for the Info-Actuator
group: "@pom.groupId@"
artifact: "@pom.artifactId@"
description: "@pom.description@"
version: "@pom.version@"
spring-boot: "@pom.parent.version@"
spring-boot-admin: "@spring-boot-admin.version@"
spring-cloud: "@spring-cloud.version@"
# Tags for the Spring Boot Admin UI
tags:
spring-boot: "@pom.parent.version@"
spring-boot-admin: "@spring-boot-admin.version@"
spring-cloud: "@spring-cloud.version@"
logging: # Logging-File for the Logfile-Actuator
file:
name: "spring-boot-admin.log"
6 changes: 4 additions & 2 deletions kubernetes/apps/spring-boot-admin-fabric8/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Spring Boot Admin

This is a Spring Boot Admin instance using spring-cloud-starter-kubernetes-fabric8 for service discovery.

## Build & Install Script

You can run the whole build and installation with the following script or follow the step by step guide below.
You can run the whole build and installation with the following script or follow the step-by-step guide below.

```bash
chmod u+x buildAndInstall.sh
Expand Down Expand Up @@ -43,7 +45,7 @@ helm uninstall spring-boot-admin-fabric8

## URI

- http://localhost/spring-boot-admin-fabric8
- http://localhost/spring-boot-admin-fabric8 (requires [traefik](../../helm-charts/traefik/README.md) to be running)

## Access Actuator
```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spring:
brand: <img src="assets/img/icon-spring-boot-admin.svg"><span>${SPRING_BOOT_ADMIN_UI_TITLE:Spring Boot Admin}</span>
discovery: # Filter discovery to tagged services
instances-metadata:
spring-boot-admin: true
spring-boot-admin: true # is added as annotation in service.yaml in helm chart

management: # Actuator Configuration
server:
Expand Down
6 changes: 4 additions & 2 deletions kubernetes/apps/spring-boot-admin-kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Spring Boot Admin

This is a Spring Boot Admin instance using spring-cloud-starter-kubernetes-client for service discovery.

## Build & Install Script

You can run the whole build and installation with the following script or follow the step by step guide below.
You can run the whole build and installation with the following script or follow the step-by-step guide below.

```bash
chmod u+x buildAndInstall.sh
Expand Down Expand Up @@ -43,7 +45,7 @@ helm uninstall spring-boot-admin-kubernetes

## URI

- http://localhost/spring-boot-admin-kubernetes
- http://localhost/spring-boot-admin-kubernetes (requires [traefik](../../helm-charts/traefik/README.md) to be running)

## Access Actuator
```bash
Expand Down
Loading