Skip to content
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
Not intended for production usage, but to reproduce issues or to try out things.

### Kubernetes
- [kubernetes-fabric8](/kubernetes-fabric8)
- [kubernetes](/kubernetes)


8 changes: 0 additions & 8 deletions kubernetes-fabric8/apps/spring-boot-admin/buildAndInstall.sh

This file was deleted.

File renamed without changes.
11 changes: 9 additions & 2 deletions kubernetes-fabric8/README.md → kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Allows to run Spring Boot Admin and two sample apps (hello world, health simulator) in kubernetes.

There are 2 instances of Spring Boot Admin available. Both use the discovery mechanism to find the apps to monitor,
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.

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

## Enable Kubernetes in Docker Desktop
Expand Down Expand Up @@ -39,7 +43,9 @@ chmod u+x buildAndInstallAll.sh
./buildAndInstallAll.sh
```

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

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

## Step-by-step Installation

Expand All @@ -50,7 +56,8 @@ http://localhost/spring-boot-admin
### Build & Install Apps

- [./apps/hello-world/README.md](./apps/hello-world/README.md)
- [./apps/spring-boot-admin/README.md](./apps/spring-boot-admin/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/health-simulator/README.md](./apps/health-simulator/README.md)

## Uninstall Everything
Expand Down
8 changes: 8 additions & 0 deletions kubernetes/apps/spring-boot-admin-fabric8/buildAndInstall.sh
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:fabric8 .
# Install App
helm upgrade --install spring-boot-admin-fabric8 ../../helm-charts/spring-boot-admin -f deployment/values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: spring-boot-admin-fabric8
namespace: default

deployment:
image: spring-boot-admin:fabric8
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?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">
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>
Expand All @@ -11,7 +11,7 @@
</parent>

<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin</artifactId>
<artifactId>spring-boot-admin-fabric8</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<version>1.0.0-SNAPSHOT</version>
Expand All @@ -20,7 +20,7 @@
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-boot-admin.version>3.0.4</spring-boot-admin.version>
<spring-boot-admin.version>3.0.5-SNAPSHOT</spring-boot-admin.version>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to merge this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have turned the version back to 3.0.4. In the spring-boot-admin-kubernetes module, however, the 3.0.5-SNAPSHOT is necessary until the next release...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since version 3.1.0 was just released, I changed the versions in both modules accordingly.

<spring-cloud.version>2022.0.2</spring-cloud.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ spring:
discovery: # Filter discovery to tagged services
instances-metadata:
spring-boot-admin: true
# Service port name must be http or https or ...
# cloud:

# kubernetes:
# discovery:
# primary-port-name: http
Expand Down
5 changes: 5 additions & 0 deletions kubernetes/apps/spring-boot-admin-kubernetes/.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-kubernetes/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"]
57 changes: 57 additions & 0 deletions kubernetes/apps/spring-boot-admin-kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Spring Boot Admin

## 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 .
```

### Install App
```bash
helm upgrade --install spring-boot-admin ../../helm-charts/spring-boot-admin
```

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

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

## URI

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

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

- http://localhost:9091/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:kubernetes .
# Install App
helm upgrade --install spring-boot-admin-kubernetes ../../helm-charts/spring-boot-admin -f deployment/values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: spring-boot-admin-kubernetes
namespace: default

deployment:
server:
port: 9090
management:
port: 9091
image: spring-boot-admin:kubernetes
88 changes: 88 additions & 0 deletions kubernetes/apps/spring-boot-admin-kubernetes/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.0.6</version>
</parent>

<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-kubernetes</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.0.5-SNAPSHOT</spring-boot-admin.version>
<spring-cloud.version>2022.0.2</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-client</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.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableAdminServer
// Enable scheduled discovery of services
@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,71 @@
server:
port: 9090
spring:
application: # Application-Infos for the Info-Actuator
name: "@pom.artifactId@"
# Spring Boot Admin
boot:
admin:
ui:
# public-url: ${SPRING_BOOT_ADMIN_UI_PUBLIC_URL:http://localhost:8080}
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

cloud:
kubernetes:
discovery:
metadata:
ports:
management: 9091
serviceLabels:
spring-boot: true

# kubernetes:
# discovery:
# primary-port-name: http
management: # Actuator Configuration
server:
port: 9091
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"
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

helm upgrade --install traefik helm-charts/traefik

cd apps/spring-boot-admin
cd apps/spring-boot-admin-kubernetes
./buildAndInstall.sh
cd ../..

cd apps/spring-boot-admin-fabric8
./buildAndInstall.sh
cd ../..

Expand Down
Loading