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
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ mvn clean install

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

### Install App
```bash
helm upgrade --install spring-boot-admin ../../helm-charts/spring-boot-admin
helm upgrade --install spring-boot-admin-fabric8 ../../helm-charts/spring-boot-admin -f deployment/values.yml
```

### Check deployment
Expand All @@ -38,12 +38,12 @@ kubectl get rolebinding -o wide

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

## URI

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

## Access Actuator
```bash
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.1.0</spring-boot-admin.version>
<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,11 +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

management: # Actuator Configuration
server:
port: 8081
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:kubernetes .
```

### Install App
```bash
helm upgrade --install spring-boot-admin-kubernetes ../../helm-charts/spring-boot-admin -f deployment/values.yml
```

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

## URI

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

## Access Actuator
```bash
kubectl get pods
```
```bash
kubectl port-forward <pod-name> 9091:9091
```
### 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.1.0</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();
}
}
Loading