easy-spring-boot

by goatfryed

Helm chartv0.5.0App 3.4.1MITVerified publisher

Unified deployment of individual spring boot applications

About this chart

Easy Spring Boot

A simple, yet flexible helm chart to deploy spring boot applications in kubernetes.
Configure all you needs as simple as possible.

  • Getting started
  • Features
    • Easy profile configuration management
    • Deployment debug mode

Getting started

helm repo add goatfryed https://goatfryed.github.io/helm-charts

Create an application.yaml with your environment specific values:

exampleApp:
  rest:
    buddyApp:
      baseUrl: http://buddyApp/api
spring:
  cache:
    type: caffeine
    caffeine:
      spec: maximumSize=500,expireAfterAccess=600s
logging:
  level:
    org.springframework: error
    com.example.myapp: debug
server:
  compression:
    enabled: true
    mime-types: application/json,text/html
    min-response-size: 1024   

Install your app:

helm install \
  my-spring-app goatfryed/easy-spring-boot \
  --set image.repository=myRegistry/myImageRepo \
  --set-file spring.config.local.values=application.yaml

Features

All configuration options are documented in this chart's values.yaml. The following documentation only highlights selected features by example and explains the purpose. For detailed configuration option, see the values.yaml.

Also check out the unit tests for usage examples.

Managed spring configuration

The following spring configuration is manged by the helm chart.

Spring bootChart
management.server.portspring.managementPort
server.portspring.serverPort
spring.application.namespring.applicationName
spring.profiles.activeprofile management
spring.config.additionalLocationinternal

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.

You can also use list active profiles explicitly under spring.profiles.active to disable some, add profiles built into your application or change the priority. Keep in mind that the last listed profile wins on overlapping definitions.

define application values directly in your helm value

The quick and easy way to get started with a service configuration. Define environment configuration directly in your values.yaml

spring:
  config:
    myProfile:
      app:
        foo: bar
      logging:
        level:
          root: WARN

define application.yaml in your devops project and inject it

This is the recommended approach for non-critical configuration properties. Store one or more simple application.yaml for your spring application and inject them as release values.

Use the helm option --set-file spring.config.myProfile.values=application.yaml to inject application.yaml files

reference existing application configuration from configMaps

If your cluster contains application.yaml or application.properties in a pre-stored configMap, you can mount them by reference into your pod

spring:
  config:
    myProfile:
      configMap:
        name: my-config-map
        key: my-key
        type: yaml

This can be a good option, if certain configuration should be shared, e.g. a config of all service urls.

reference existing application configuration from secrets

As above, but for secrets

spring:
  config:
    myProfile:
      secret:
        name: user-defined-config-map
        key: app.yml
        type: yaml

Debug convenience to get started

The chart comes with a debug flag to easily start the pod in save mode to investigate further. For example during development, this can be handy, if your application keeps failing to start and you want to exec into a container to run it manually, check the mounted configuration or other things.

Of course, you could simply have a values.debug.yaml that you apply additionally, for these cases. The main reason for this feature is convenience and the option to quickly toggle debug mode via helm upgrade my-release goatfryed/easy-spring-boot --reuse-values --set debugDeployment.enabled=true|false

start pod without a running application

By default, if debugDeployment is enabled, the pod will start with inactive health checks and simply wait for shutdown. This allows you to exec into it and investigate in the cluster.

use a debug profile configuration

You can also configure debug mode to use a different the of active profiles for advanced insight

spring:
  profiles:
    active: 'local,database,k8sServices,logging,performance'
debugDeployment:
  overrideProfiles: 'local,database,k8sServices,chatty-logging'

This example assumes that all the mentioned profile configuration was configured as explained in the configuration section or built into the application.

Configuration updates

Kubernetes doesn't update pods, when your mounted configuration or secrets change. By default, a checksum of enabled application configuration defined in helm values is added to your pod. This cases your pod to be recreated, when you update the configuration.

Check chart configuration options deployment.recreatePodStrategy.

If you mount external configuration, you can add your own label with a change date.

Advanced configuration

The included configuration support is aimed at simple to medium requirements. For more advanced use cases, consider spring-cloud-config

Contributing

Looking to contribute? Great! Check out CONTRIBUTING.md

Deploy easy-spring-boot with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has easy-spring-boot on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the charteasy-spring-boot is pinned at v0.5.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply