Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions charts/better-spring-boot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Also because other available helm charts for spring services are poorly document
- [Getting started](#getting-started)
- [Features](#features)
- [Easy profile configuration management](#easy-profile-configuration-management)
- [Deployment debug mode](#)
- [Deployment debug mode](#debug-convenience-to-get-started)

## Promises
**One chart to rule them all:**\
Expand Down Expand Up @@ -61,6 +61,17 @@ Also check out the [unit tests](./tests) for usage examples.

We are terrible sorry to not provide a better documentation at the moment!

## Managed spring configuration
The following spring configuration is manged by the helm chart.

| Spring boot | Chart |
|----------------------------------|--------------------------------------------------------------|
| server.port | spring.serverPort |
| spring.application.name | spring.applicationName |
| spring.profiles.active | [profile management](#easy-profile-configuration-management) |
| spring.config.additionalLocation | *internal* |


## Easy profile configuration management
You can configure profile specific application properties under `spring.config.{myProfileName}` from different sources.
By default, all configured profiles are activated ordered by name.
Expand All @@ -76,8 +87,8 @@ values.yaml
spring:
config:
myProfile:
server:
port: 80
app:
foo: bar
logging:
level:
root: WARN
Expand Down
11 changes: 9 additions & 2 deletions charts/better-spring-boot/templates/_helpers_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ release/roll-me: {{ print .Release.Revision "-" (randAlphaNum 5) | quote }}

{{- define "better-spring-boot.deployment.containerEnv" }}
{{- $envVars := .Values.spring.environmentVariable }}
{{- $envVars = omit $envVars "SPRING_PROFILES_ACTIVE" "SPRING_CONFIG_ADDITIONAL_LOCATION" "SPRING_APPLICATION_NAME" }}
{{- $envVars = omit $envVars
"SPRING_PROFILES_ACTIVE"
"SPRING_CONFIG_ADDITIONAL_LOCATION"
"SPRING_APPLICATION_NAME"
"SERVER_PORT"
}}
{{- range $key, $value := $envVars }}
{{- if ne $value nil }}
- name: {{ $key }}
value: {{ default "''" $value }}
value: {{ default "" $value | toString | toJson }}
{{- end }}
{{- end }}
{{- $activeProfiles := include "better-spring-boot.deploymentactiveProfiles" . }}
Expand All @@ -47,6 +52,8 @@ release/roll-me: {{ print .Release.Revision "-" (randAlphaNum 5) | quote }}
{{- end }}
- name: SPRING_CONFIG_ADDITIONAL_LOCATION
value: optional:/app/config/*/
- name: SERVER_PORT
value: {{ .Values.spring.serverPort | default .Values.service.port | toString | toJson }}
{{- end }}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ injects application properties spring-container:
value: RELEASE-NAME
- name: SPRING_CONFIG_ADDITIONAL_LOCATION
value: optional:/app/config/*/
- name: SERVER_PORT
value: "8080"
image: goatfryed/spring-boot-echo:latest
imagePullPolicy: IfNotPresent
name: spring-boot
Expand Down Expand Up @@ -68,6 +70,8 @@ mounts configuration values:
value: RELEASE-NAME
- name: SPRING_CONFIG_ADDITIONAL_LOCATION
value: optional:/app/config/*/
- name: SERVER_PORT
value: "8080"
image: goatfryed/spring-boot-echo:latest
imagePullPolicy: IfNotPresent
name: spring-boot
Expand Down Expand Up @@ -100,6 +104,8 @@ mounts referenced configMaps:
value: RELEASE-NAME
- name: SPRING_CONFIG_ADDITIONAL_LOCATION
value: optional:/app/config/*/
- name: SERVER_PORT
value: "8080"
image: goatfryed/spring-boot-echo:latest
imagePullPolicy: IfNotPresent
name: spring-boot
Expand Down Expand Up @@ -139,6 +145,8 @@ mounts referenced secrets:
value: RELEASE-NAME
- name: SPRING_CONFIG_ADDITIONAL_LOCATION
value: optional:/app/config/*/
- name: SERVER_PORT
value: "8080"
image: goatfryed/spring-boot-echo:latest
imagePullPolicy: IfNotPresent
name: spring-boot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ works with maximal configuration:
value: myAwesomeApplication
- name: SPRING_CONFIG_ADDITIONAL_LOCATION
value: optional:/app/config/*/
- name: SERVER_PORT
value: "8083"
image: user-registry/user-repo:user-tag
imagePullPolicy: Always
livenessProbe:
Expand Down Expand Up @@ -323,6 +325,8 @@ works with minimal configuration:
value: RELEASE-NAME
- name: SPRING_CONFIG_ADDITIONAL_LOCATION
value: optional:/app/config/*/
- name: SERVER_PORT
value: "8080"
image: goatfryed/spring-boot-echo:latest
imagePullPolicy: IfNotPresent
livenessProbe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ adds health checks only if explicitly activated:
value: RELEASE-NAME
- name: SPRING_CONFIG_ADDITIONAL_LOCATION
value: optional:/app/config/*/
- name: SERVER_PORT
value: "8080"
image: goatfryed/spring-boot-echo:latest
imagePullPolicy: IfNotPresent
name: spring-boot
Expand Down Expand Up @@ -42,6 +44,8 @@ overrides profiles:
value: RELEASE-NAME
- name: SPRING_CONFIG_ADDITIONAL_LOCATION
value: optional:/app/config/*/
- name: SERVER_PORT
value: "8080"
image: goatfryed/spring-boot-echo:latest
imagePullPolicy: IfNotPresent
name: spring-boot
Expand Down Expand Up @@ -76,6 +80,8 @@ overrides run command:
value: RELEASE-NAME
- name: SPRING_CONFIG_ADDITIONAL_LOCATION
value: optional:/app/config/*/
- name: SERVER_PORT
value: "8080"
image: goatfryed/spring-boot-echo:latest
imagePullPolicy: IfNotPresent
name: spring-boot
Expand Down
46 changes: 35 additions & 11 deletions charts/better-spring-boot/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ tests:
set:
image.repository: goatfryed/spring-boot-echo
spring.environmentVariable:
FOO: BAR
FOO: 8080
CHUCK: NORRIS
MUTE: ""
SILENT: ~
Expand All @@ -102,7 +102,7 @@ tests:
path: spec.template.spec.containers[0].env
content:
name: FOO
value: BAR
value: "8080"
- template: deployment.yaml
contains:
path: spec.template.spec.containers[0].env
Expand Down Expand Up @@ -205,13 +205,12 @@ tests:
suite: deployment/application name
templates:
- deployment.yaml
- configMap.appConfig.yaml
values:
- "values/values.base.yaml"
tests:
- it: sets spring application name to user provided name
set:
spring.applicationName: myAwesomeApp
values:
- "values/values.base.yaml"
asserts:
- template: deployment.yaml
contains:
Expand All @@ -220,8 +219,6 @@ tests:
name: SPRING_APPLICATION_NAME
value: myAwesomeApp
- it: sets spring application name to release name by default
values:
- "values/values.base.yaml"
asserts:
- template: deployment.yaml
contains:
Expand All @@ -230,8 +227,6 @@ tests:
name: SPRING_APPLICATION_NAME
value: RELEASE-NAME
- it: follows full name override by default
values:
- "values/values.base.yaml"
set:
fullnameOverride: myApplicationName
asserts:
Expand All @@ -242,15 +237,44 @@ tests:
name: SPRING_APPLICATION_NAME
value: myApplicationName
- it: backs off from name configuration
values:
- "values/values.base.yaml"
set:
spring.applicationName: false
asserts:
- template: deployment.yaml
notEqual:
path: spec.template.spec.containers[0].env[*].name
value: SPRING_APPLICATION_NAME
---
suite: deployment/ports
templates:
- deployment.yaml
values:
- "values/values.base.yaml"
tests:
- it: manages server port
set:
spring.environmentVariable.SERVER_PORT: "123"
asserts:
- notContains:
path: spec.template.spec.containers[0].env
content:
name: SERVER_PORT
value: "123"
- it: sets server port
asserts:
- template: deployment.yaml
contains:
path: spec.template.spec.containers[0].ports
content:
containerPort: 8080
name: http
protocol: TCP
- template: deployment.yaml
contains:
path: spec.template.spec.containers[0].env
content:
name: SERVER_PORT
value: "8080"



2 changes: 1 addition & 1 deletion charts/better-spring-boot/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spring:
# nil -> sets spring application name equal to release name or fullnameOverride
# false -> opt out of name management. e.g. if you provide the name built into your image
applicationName: ~
# if you configure server.port in your spring application, set this to the same value
# sets server.port and named port http, defaults to service.port
serverPort: 8080
# if you configure management.server.port, set this to the same value
managementPort: ~
Expand Down